How to use the mocha.it function in mocha

To help you get started, we’ve selected a few mocha 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 googleapis / nodejs-redis / test / gapic-cloud_redis-v1.ts View on Github external
client
        .exportInstance(request)
        .then((responses: [Operation]) => {
          const operation = responses[0];
          return operation ? operation.promise() : {};
        })
        .then((responses: [Operation]) => {
          assert.deepStrictEqual(responses[0], expectedResponse);
          done();
        })
        .catch((err: {}) => {
          done(err);
        });
    });

    it('invokes exportInstance with error', done => {
      const client = new cloudredisModule.v1.CloudRedisClient({
        credentials: {client_email: 'bogus', private_key: 'bogus'},
        projectId: 'bogus',
      });
      // Mock request
      const request: protosTypes.google.cloud.redis.v1.IExportInstanceRequest = {};
      // Mock response
      const expectedResponse = {};
      // Mock gRPC layer
      client._innerApiCalls.exportInstance = mockLongRunningGrpcMethod(
        request,
        null,
        error
      );
      client
        .exportInstance(request)
github GPMDP / google-play-music-desktop-remote / test / stores / WebSocketStore.js View on Github external
it('sends a toggleShuffle message', () => {
    webSocketStore.sendToggleShuffle()
    expect(webSocketStore.webSocket.lastmessage).to.deep.equal(
      JSON.stringify({ namespace: 'playback', method: 'toggleShuffle' })
    )
  })

  it('sends a getRepeat message', () => {
    webSocketStore.sendGetRepeat()
    expect(webSocketStore.webSocket.lastmessage).to.deep.equal(
      JSON.stringify({ namespace: 'playback', method: 'getRepeat' })
    )
  })

  it('sends a toggleRepeat message', () => {
    webSocketStore.sendToggleRepeat()
    expect(webSocketStore.webSocket.lastmessage).to.deep.equal(
      JSON.stringify({ namespace: 'playback', method: 'toggleRepeat' })
    )
  })

  it('sends a setTime message', () => {
    webSocketStore.sendSetTime(100)
    expect(webSocketStore.webSocket.lastmessage).to.deep.equal(
      JSON.stringify({ namespace: 'playback', method: 'setPlaybackTime', arguments: [100] })
    )
    expect(trackStore.stop.calledOnce).to.be.true
  })
})
github graphql / graphql-js / src / validation / __tests__ / ScalarLeafs.js View on Github external
fragment scalarSelectionWithArgs on Dog {
        doesKnowCommand(dogCommand: SIT)
      }
    `);
  });

  it('scalar selection not allowed on Boolean', () => {
    expectFailsRule(ScalarLeafs, `
      fragment scalarSelectionsNotAllowedOnBoolean on Dog {
        barks { sinceWhen }
      }
    `,
    [ noScalarSubselection('barks', 'Boolean', 3, 15) ] );
  });

  it('scalar selection not allowed on Enum', () => {
    expectFailsRule(ScalarLeafs, `
      fragment scalarSelectionsNotAllowedOnEnum on Cat {
        furColor { inHexdec }
      }
    `,
    [ noScalarSubselection('furColor', 'FurColor', 3, 18) ] );
  });

  it('scalar selection not allowed with args', () => {
    expectFailsRule(ScalarLeafs, `
      fragment scalarSelectionsNotAllowedWithArgs on Dog {
        doesKnowCommand(dogCommand: SIT) { sinceWhen }
      }
    `,
    [ noScalarSubselection('doesKnowCommand', 'Boolean', 3, 42) ] );
  });
github graphql / graphql-js / src / type / __tests__ / validation.js View on Github external
const AnotherObject = new GraphQLObjectType({
        name: 'AnotherObject',
        interfaces: [ AnotherInterface ],
        fields: {
          anotherfield: { type: GraphQLString }
        }
      });

      return schemaWithFieldType(AnotherObject);
    }).to.throw(
      '"AnotherInterface" expects field "field" but ' +
      '"AnotherObject" does not provide it.'
    );
  });

  it('rejects an Object with an incorrectly typed Interface field', () => {
    expect(() => {
      const AnotherInterface = new GraphQLInterfaceType({
        name: 'AnotherInterface',
        resolveType: () => null,
        fields: {
          field: { type: GraphQLString }
        }
      });

      const AnotherObject = new GraphQLObjectType({
        name: 'AnotherObject',
        interfaces: [ AnotherInterface ],
        fields: {
          field: { type: SomeScalarType }
        }
      });
github graphql / graphql-js / src / type / __tests__ / introspection.js View on Github external
describe('Introspection', () => {
  it('executes an introspection query', async () => {
    const EmptySchema = new GraphQLSchema({
      query: new GraphQLObjectType({
        name: 'QueryRoot',
        fields: {
          onlyField: { type: GraphQLString }
        }
      })
    });

    return expect(
      await graphql(EmptySchema, introspectionQuery)
    ).to.containSubset({
      data: {
        __schema: {
          mutationType: null,
          subscriptionType: null,
github googleapis / nodejs-bigtable / test / app-profile.ts View on Github external
assert.strictEqual(config.client, 'BigtableInstanceAdminClient');
        assert.strictEqual(config.method, 'getAppProfile');

        assert.deepStrictEqual(config.reqOpts, {
          name: appProfile.name,
        });

        assert.deepStrictEqual(config.gaxOpts, {});

        done();
      };

      appProfile.getMetadata(assert.ifError);
    });

    it('should accept gaxOptions', function(done) {
      const gaxOptions = {};

      appProfile.bigtable.request = function(config) {
        assert.strictEqual(config.gaxOpts, gaxOptions);
        done();
      };

      appProfile.getMetadata(gaxOptions, assert.ifError);
    });

    it('should update metadata', function(done) {
      const metadata = {};

      appProfile.bigtable.request = function(config, callback) {
        callback(null, metadata);
      };
github std4453 / bilibili-danmaku-client / test / application / definitions.js View on Github external
roomid: 1234,
            uid: '5678',
            uname: 'Joe',
        };
        const outputTemplate = {
            roomId: 1234,
            blocked: {
                uid: 5678,
                name: 'Joe',
            },
        };

        test(inputTemplate, outputTemplate, {});
    });

    it('should transform ROOM_SILENT_ON correctly', () => {
        const inputTemplate = {
            cmd: 'ROOM_SILENT_ON',
            roomid: 1234,
            data: mock => ({
                type: mock.type,
                second: 5678,
                ...mock.params,
            }),
        };
        const outputTemplate = mock => ({
            roomId: 1234,
            second: 5678,
            type: mock.type,
            ...mock.params,
        });
        const mockTemplate = chooseFrom({
github googleapis / nodejs-bigtable / test / family.ts View on Github external
it('should return false if FamilyError', function(done) {
      const error = new FamilyError('Error.');

      family.getMetadata = function(gaxOptions, callback) {
        callback(error);
      };

      family.exists(function(err, exists) {
        assert.ifError(err);
        assert.strictEqual(exists, false);
        done();
      });
    });

    it('should return error if not FamilyError', function(done) {
      const error = new Error('Error.');

      family.getMetadata = function(gaxOptions, callback) {
        callback(error);
      };

      family.exists(function(err) {
        assert.strictEqual(err, error);
        done();
      });
    });

    it('should return true if no error', function(done) {
      family.getMetadata = function(gaxOptions, callback) {
        callback(null, {});
      };
github faultline / faultline / src / handlers / __tests__ / occurrencesGet.js View on Github external
};
        const context = {};
        return mockAws.createResources().then(() => {
            return new Promise((resolve) => {
                errorsPostHandler(event, context, (error, response) => {
                    resolve();
                });
            });
        });
    });

    afterEach(() => {
        return mockAws.deleteResources();
    });

    it ('GET error occrrence, response.statusCode should be 200', () => {
        const unixtime = moment('2016-11-02T00:01:00+00:00').unix();
        const event = {
            httpMethod: 'GET',
            headers: {
                'X-Api-Key': process.env.FAULTLINE_MASTER_API_KEY
            },
            pathParameters: {
                project: encodeURIComponent('sample-project'),
                message: encodeURIComponent('Undefined index: faultline'),
                reversedUnixtime: encodeURIComponent(reversedUnixtime(unixtime))
            }
        };
        const context = {};

        return new Promise((resolve) => {
            const cb = (error, response) => {
github apache / incubator-superset / superset / assets / spec / javascripts / explore / components / FilterControl_spec.jsx View on Github external
],
    });
  });

  it('renders Filters', () => {
    expect(
      React.isValidElement(),
    ).to.equal(true);
  });

  it('renders one button and two filters', () => {
    expect(wrapper.find(Filter)).to.have.lengthOf(2);
    expect(wrapper.find(Button)).to.have.lengthOf(1);
  });

  it('adds filter when clicking Add Filter', () => {
    const addButton = wrapper.find('#add-button');
    expect(addButton).to.have.lengthOf(1);
    addButton.simulate('click');
    expect(defaultProps.onChange).to.have.property('callCount', 1);
    expect(defaultProps.onChange.getCall(0).args[0]).to.deep.equal([
      {
        col: 'col1',
        op: 'in',
        val: ['a', 'b', 'd'],
      },
      {
        col: 'col2',
        op: '==',
        val: 'Z',
      },
      {