2017-05-25 20:09:29 +07:00
|
|
|
|
|
|
|
import sinon = require("sinon");
|
|
|
|
import assert = require("assert");
|
|
|
|
|
2017-10-07 05:09:42 +07:00
|
|
|
import UISelector = require("../../src/lib/totp-register/ui-selector");
|
|
|
|
import TOTPRegister = require("../../src/lib/totp-register/totp-register");
|
2017-05-25 20:09:29 +07:00
|
|
|
|
|
|
|
describe("test totp-register", function() {
|
|
|
|
let jqueryMock: any;
|
|
|
|
let windowMock: any;
|
|
|
|
before(function() {
|
|
|
|
jqueryMock = sinon.stub();
|
|
|
|
windowMock = {
|
|
|
|
QRCode: sinon.spy()
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should create qrcode in page", function() {
|
|
|
|
const mock = {
|
|
|
|
text: sinon.stub(),
|
|
|
|
empty: sinon.stub(),
|
|
|
|
get: sinon.stub()
|
|
|
|
};
|
|
|
|
jqueryMock.withArgs(UISelector.QRCODE_ID_SELECTOR).returns(mock);
|
|
|
|
|
|
|
|
TOTPRegister.default(windowMock, jqueryMock);
|
|
|
|
|
|
|
|
assert(mock.text.calledOnce);
|
|
|
|
assert(mock.empty.calledOnce);
|
|
|
|
});
|
|
|
|
});
|