How to use the @oclif/test.test.nock function in @oclif/test

To help you get started, we’ve selected a few @oclif/test examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HAECHI-LABS / henesis-cli / src / commands / account / changepw.spec.ts View on Github external
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');
        });
github HAECHI-LABS / henesis-cli / src / commands / integration / status.spec.ts View on Github external
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');
  });
});
github HAECHI-LABS / henesis-cli / src / commands / integration / describe.spec.ts View on Github external
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',
        );
      });
  });
github HAECHI-LABS / henesis-cli / src / commands / integration / delete.spec.ts View on Github external
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`);
      });
  });
github HAECHI-LABS / henesis-cli / src / commands / login.spec.ts View on Github external
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);

@oclif/test

test helpers for oclif components

MIT
Latest version published 14 days ago

Package Health Score

84 / 100
Full package analysis