Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async (): Promise => {
before((): void => {
configstore.set('user', {
email: 'yoonsung@haechi.io',
name: 'ys.choi',
organization: 'haechilabs',
jwtToken: 'asdf',
id: 43,
});
});
test
.nock(
'http://localhost:8080',
(api): Scope => api.patch('/users/v1/passwd').reply(200, {}),
)
.stub(
utils,
'passwordPrompt',
async (): Promise => {
return Promise.resolve('12345678');
},
)
.stdout()
.command(['account:changepw'])
.it('should be success Password change', (ctx): void => {
expect(ctx.stdout).to.equal('🦄 Password changed!\n');
});
context('When error occurred', (): void => {
test
.nock(
'http://localhost:8080',
(api): Scope =>
api.get('/integrations/v1').reply(400, 'error occurred'),
)
.stdout()
.command(['integration:status'])
.exit(2)
.it('exit with status 2 when fail to getIntegrations');
});
});
context('when no error occurred', (): void => {
const integration = newMockIntegration();
test
.nock(
'http://localhost:8080',
(api): Scope =>
api
.get('/integrations/v1/' + integration.integrationId)
.reply(200, integration),
)
.stdout()
.command([`integration:describe`, integration.integrationId])
.it('describe a integration', (ctx): void => {
expect(ctx.stdout).to.equal(
JSON.stringify(integration, undefined, 2) + '\n',
);
});
});
context('when no error occurred', (): void => {
const id = 'integrationId';
test
.nock(
'http://localhost:8080',
(api): Scope => api.delete('/integrations/v1/' + id).reply(200, ''),
)
.stdout()
.command([`integration:delete`, id])
.it('delete a integration', (ctx): void => {
expect(ctx.stdout).to.equal(`${id} has been deleted\n`);
});
});
describe('login', (): void => {
test
.nock(
'http://localhost:8080',
(api): Scope =>
api.post('/users/v1/login').reply(200, {
email: 'yoonsung@haechi.io',
name: 'ys.choi',
organization: 'haechilabs',
jwtToken: 'asdf',
id: 43,
}),
)
.stub(
utils,
'confirmPrompt',
async (): Promise => {
return Promise.resolve(true);