assert.throws(function () { throw new Error('bang!') })
assert.throws(function () {})
it('throws when a parent cannot be returned', () => { const p = new Path(''); assert.deepEqual(p.elements(), []); assert.ok(!p.hasParent()); assert.throws(() => p.parent()); });
async function assertThrowsAsync (fn, regExp) { let f = () => {} try { await fn() } catch (e) { f = () => { throw e } } finally { assert.throws(f, regExp) } }
invalidSetOfOptions.forEach(invalidOptions => { it(`must throw exception, cuz family option is invalid ${JSON.stringify(invalidOptions)}`, () => { const cb = () => {}; const resolveStub = sinon.stub(lookup, '_resolve'); const resolveBothStub = sinon.stub(lookup, '_resolveBoth'); assert.throws(() => { lookup.run(hostname, invalidOptions, cb); }, Error, 'invalid family number, must be one of the {4, 6} or undefined'); assert.isTrue(resolveStub.notCalled); assert.isTrue(resolveBothStub.notCalled); }); });
describe( 'setPreset', function () { describe( 'when passed other value than "drupal"', function(){ it( 'should throw', function () { assert.throws( () => webpack.setPreset('wordpress'), Error ); } ); } ); } );
it('allows another object in constructor, produces JSON', () => { const bc1 = new FileCoverage('/path/to/file'); const bc2 = new FileCoverage(bc1); assert.equal(bc2.path, '/path/to/file'); const bc3 = new FileCoverage(bc1.data); assert.equal(bc3.path, '/path/to/file'); assert.deepEqual(bc1.data, JSON.parse(JSON.stringify(bc3))); delete bc3.data.s; assert.throws(() => { new FileCoverage(bc3.data); }); });
describe('getKey', function() { it('should remove the first character of a string', function() { var f = new UrlFormatter(); assert.equal(f.getKey(':key'), 'key'); assert.equal(f.getKey('key'), 'ey'); assert.throws(f.getKey, TypeError); }); });
it("Invalid type for Gizmo, valid types are: 'query' or 'shape'.", function() { assert.throws(function() { cayleyClient.g.type('lalala').V().All(); }); });
describe('Check params Helpers', () => { it('should throw an error', () => { assert.throws(helpers.checkParams, Error, 'Provide options'); }); it('should not throw an error', () => { assert.equal(helpers.checkParams({ docsLink: '/link/to/docs', }), true); }); });
describe('perror', function() { it('should create a PError', function() { const err = new PError('%s'); assert.equal(err.message, '%s'); }); it('should not allow multiple arguments', function() { assert.throws(function() { console.error(new PError('%s', 'foo')); }, /only one argument is allowed with options.skipPrintf/); }); });
it('does not allow construction with random input', () => { assert.throws(() => new Path({})); });
it('throws when a parent cannot be returned', () => { const p = new Path(''); assert.deepEqual(p.elements(), []); assert.ok(!p.hasParent()); assert.throws(() => p.parent()); });
it("'promisify' was set to false, but no 'callback' provided.", function() { assert.throws(function() { cayleyClient.g.type('query').V().All(); }, Error); });