-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinteractive.test.ts
More file actions
50 lines (45 loc) · 1.34 KB
/
interactive.test.ts
File metadata and controls
50 lines (45 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { expect } from 'chai';
import * as sinon from 'sinon';
import { interactive } from '../../src/utils';
import { cliux } from '@contentstack/cli-utilities';
<<<<<<< HEAD
import { readFileSync } from 'fs';
import { join } from 'path';
const config = JSON.parse(readFileSync(join(__dirname, './config.json'), "utf-8"));
=======
//@ts-ignore
import * as config from './config.json'
>>>>>>> main
describe('Interactive', () => {
let inquireStub: sinon.SinonStub;
beforeEach(function () {
inquireStub = sinon.stub(cliux, 'inquire');
});
afterEach(function () {
inquireStub.restore();
});
it('ask otp channel', async function () {
const channel = 'authy';
inquireStub.callsFake(function () {
return Promise.resolve(channel);
});
const result = await interactive.askOTPChannel();
expect(result).to.be.equal(channel);
});
it('ask otp', async function () {
const otp = '22222';
inquireStub.callsFake(function () {
return Promise.resolve(otp);
});
const result = await interactive.askOTP();
expect(result).to.be.equal(otp);
});
it('ask password', async function () {
const password = config.password
inquireStub.callsFake(function () {
return Promise.resolve(password);
});
const result = await interactive.askPassword();
expect(result).to.be.equal(password);
});
});