How to use the mocha.test 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 ubiq / shokku / test / server / ticker.controller.tests.js View on Github external
const r = await request(server)
      .get('/v1/ticker/ubqeur')
      .expect(200)

    expectTickerResponse(r)
  })

  test('when req -> /v1/ticker/ubqltc | resp -> 200', async () => {
    const r = await request(server)
      .get('/v1/ticker/ubqeur')
      .expect(200)

    expectTickerResponse(r)
  })

  test('when req -> /v1/ticker/invalid | resp -> 400', async () =>
    await request(server)
      .get('/v1/ticker/invalid')
      .expect(404))
})
github ubiq / shokku / test / server / jsonrpc.controller.tests.js View on Github external
expectStandardResponse(r)
          }
        })

        test('params [] | resp -> 400', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getWork?params=[]`)
              .expect('Content-Type', /json/)
              .expect(200)

            expectStandardResponse(r)
          }
        })

        test('params [invalid] | resp -> 400', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getWork?params=["invalid"]`)
              .expect('Content-Type', /json/)
              .expect(400)

            expectStandardErrorResponse(r)
          }
        })
      })
    })
github ubiq / shokku / test / server / jsonrpc.controller.tests.js View on Github external
}
        })

        test('params [earliest] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["earliest"]`)
              .expect('Content-Type', /json/)
              .expect(200)

            expectStandardResponse(r)
            expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
          }
        })

        test('params [latest] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["latest"]`)
              .expect('Content-Type', /json/)
              .expect(200)

            expectStandardResponse(r)
            expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
          }
        })

        test('params [pending] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["pending"]`)
              .expect('Content-Type', /json/)
github ubiq / shokku / test / server / jsonrpc.controller.tests.js View on Github external
}
        })

        test('params [latest] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["latest"]`)
              .expect('Content-Type', /json/)
              .expect(200)

            expectStandardResponse(r)
            expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
          }
        })

        test('params [pending] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_getBlockTransactionCountByNumber?params=["pending"]`)
              .expect('Content-Type', /json/)
              .expect(200)

            expectStandardResponse(r)
            expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x') || n === '')
          }
        })
      })
    })
github bookercodes / communitycasts.co / tests / index.js View on Github external
.set('Authorization', authHeader)
      .send({
        url: screencastUrl,
        tags: 'foo,bar'
      })
    const result = await request(app)
      .post('/api/screencasts')
      .set('Authorization', authHeader)
      .send({
        url: screencastUrl,
        tags: 'foo,bar'
      })
    expect(result.statusCode).to.equal(409)
  })

  test('Invalid POST with invalid url should return 400', async () => {
    const password = config.adminPassword
    const encodedPassword = new Buffer(password).toString('base64')
    const authHeader = `Basic: ${encodedPassword}`
    const {statusCode} = await request(app)
      .post('/api/screencasts')
      .set('Authorization', authHeader)
      .send({
        url: 'foo'
      })

    expect(statusCode).to.equal(400)
  })

  test('Invalid POST with missing req body should return 400', async () => {
    const password = config.adminPassword
    const encodedPassword = new Buffer(password).toString('base64')
github ubiq / shokku / test / server / jsonrpc.controller.tests.js View on Github external
for (const network of networks) {
              const url = [
                `/v1/jsonrpc/${network}/eth_call?params=`,
                '[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155", "invalidkey": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, "earliest"]'
              ].join('')
              const r = await request(server)
                .get(url)
                .expect('Content-Type', /json/)
                .expect(400)

              expectStandardErrorResponse(r)
            }
          }
        )

        test('params [{to: 0xb60e8dd61c5d32be8058bb8eb970870f07233155}, earliest] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_call?params=[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, "earliest"]`)
              .expect('Content-Type', /json/)
              .expect(200)

            expectStandardResponse(r)
            expect(r.body.result).to.satisfy(n => _.isNumber(n) || _.startsWith(n, '0x'))
          }
        })

        test('params [{to: 0xb60e8dd61c5d32be8058bb8eb970870f07233155}, latest] | resp -> 200', async () => {
          for (const network of networks) {
            const r = await request(server)
              .get(`/v1/jsonrpc/${network}/eth_call?params=[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}, "latest"]`)
              .expect('Content-Type', /json/)
github ubiq / shokku / test / server / jsonrpc.controller.tests.js View on Github external
describe('when req -> /v1/jsonrpc/{network}/ | body: eth_sendRawTransaction', () => {
        test('body [method] | resp -> 400', async () => {
          for (const network of networks) {
            const r = await request(server)
              .post(`/v1/jsonrpc/${network}/`)
              .send({
                method: 'eth_sendRawTransaction'
              })
              .expect('Content-Type', /json/)
              .expect(400)

            expectStandardErrorResponse(r)
          }
        })

        test('body [id, method] | resp -> 400', async () => {
          for (const network of networks) {
            const r = await request(server)
github gridgain / gridgain / modules / web-console / frontend / app / filters / bytes.filter.spec.js View on Github external
suite('bytes filter', () => {
    test('bytes filter', () => {
        assert.equal(bytesFilterInstance(0), '0 bytes');
        assert.equal(bytesFilterInstance(1000), '1000.0 bytes');
        assert.equal(bytesFilterInstance(1024), '1.0 kB');
        assert.equal(bytesFilterInstance(5000), '4.9 kB');
        assert.equal(bytesFilterInstance(1048576), '1.0 MB');
        assert.equal(bytesFilterInstance(104857600), '100.0 MB');
        assert.equal(bytesFilterInstance(1073741824), '1.0 GB');
        assert.equal(bytesFilterInstance(1099511627776), '1.0 TB');
    });
});
github gridgain / gridgain / modules / web-console / frontend / app / modules / agent / AgentManager.service.spec.ts View on Github external
suite('Agent manager service', () => {
    test('allFeatures', () => {
        const cluster: ClusterStats  = {supportedFeatures: '+/l9'};

        const service = new AgentManager();

        const features = service.allFeatures(cluster);

        assert.ok(features.includes(IgniteFeatures.INDEXING));
        assert.ok(features.includes(IgniteFeatures.WC_SNAPSHOT_CHAIN_MODE));
        assert.ok(features.includes(IgniteFeatures.WC_ROLLING_UPGRADE_STATUS));
    });

    test('noFeaturesOnOldNode', () => {
        const cluster: ClusterStats  = {supportedFeatures: null};

        const service = new AgentManager();

        const features = service.allFeatures(cluster);

        assert.isNotOk(features.includes(IgniteFeatures.INDEXING));
        assert.isNotOk(features.includes(IgniteFeatures.WC_SNAPSHOT_CHAIN_MODE));
        assert.isNotOk(features.includes(IgniteFeatures.WC_ROLLING_UPGRADE_STATUS));
    });
});
github gridgain / gridgain / modules / web-console / frontend / app / components / page-configure / services / ConfigurationDownload.spec.js View on Github external
suite.skip('page-configure, ConfigurationDownload service', () => {
    test('fails and shows error message when cluster not found', () => {
        const service = new Provider(...mocks().values());

        return service.downloadClusterConfiguration({_id: 1, name: 'An Cluster'})
        .then(() => Promise.reject('Should not happen'))
        .catch(() => {
            assert.equal(
                service.messages.showError.getCall(0).args[0],
                'Failed to generate project files. Cluster An Cluster not found',
                'shows correct error message when cluster was not found'
            );
        });
    });
    test('fails and shows error message when summary zipper fails', () => {
        const service = new Provider(...mocks().values());
        const cluster = {_id: 1, name: 'An Cluster'};
        service.configuration._clusters = [cluster];
        service.summaryZipper = () => Promise.reject({message: 'Summary zipper failed.'});

        return service.downloadClusterConfiguration(cluster)
        .then(() => Promise.reject('Should not happen'))
        .catch(() => {
            assert.equal(
                service.messages.showError.getCall(0).args[0],
                'Failed to generate project files. Summary zipper failed.',
                'shows correct error message when summary zipper fails'
            );
        });
    });
    test('calls correct dependcies', () => {