assert.throws(function () { throw new Error('bang!') })
assert.throws(function () {})
function testPassNonPointerSync(declaration) { const writeString = lib.interface.writeString; assert(_.isFunction(writeString)); assert(writeString.function); assert.equal(writeString.function.toString(), declaration); assert.throws(() => { writeString(42); }); assert.throws(() => { writeString(); }); }
it('pay a term and update contract duration', () => { const contract = Contract.create({begin: '01/01/2017 00:00', end: '31/12/2025 23:59', frequency: 'months', properties: [{}, {}]}); Contract.payTerm(contract, '01/12/2025 00:00', {payments:[{amount: 200}], discounts:['discount']}); const newContract = Contract.update(contract, {begin:'01/01/2019 00:00', end: '31/12/2025 23:59'}); assert.strictEqual(newContract.rents.find(rent => rent.term === 2025120100).payments[0].amount, 200); // payment out of contract time frame assert.throws(() => { Contract.update(contract, {begin:'01/01/2019 00:00', end: '31/12/2024 23:59'}); }); });
test('should requireAction', () => { requireAction(require.resolve('./app/modules/foo/lib')); Assert.throws(() => { requireAction('none'); }, /Failed to load action none/); });
it('should throw an error when callback is not specified', function() { var gc = new GithubContent({ owner: 'doowb', repo: 'github-content', branch: 'master' }); assert.throws(function() { gc.file('package.json'); }); });
it('bone.attribute(name)', async function() { const post = new Post({ title: 'Untitled' }); assert.equal(post.attribute('title'), 'Untitled'); post.title = 'New Post'; assert.equal(post.title, 'New Post'); assert.throws(() => post.attribute('missing attribute'), /no attribute/); });
it('notifyUI: throws error if socket closed or not authenticated', () => { ws = createTestWSv2Instance() const n = { type: 'info', message: 'test' } assert.throws(() => ws.notifyUI(n)) ws._isOpen = true assert.throws(() => ws.notifyUI(n)) ws._isAuthenticated = true ws.send = () => {} assert.doesNotThrow(() => ws.notifyUI(n)) })
assert.throws(() => hostValidation({ hosts: [5] }), (err) => { return err.message === '5 is not an allowed Host/Referer type. Host/Referer values must be either strings or regular expression objects.' })
it('should throw for not supported indexing', function () { const IntArray = new ArrayType('int'); const arr = new IntArray([1, 2, 3]); assert.throws(() => arr[0]); assert.throws(() => arr[1]); assert.throws(() => arr[2]); assert.throws(() => arr[3]); assert.throws(() => arr[4]); assert.throws(() => arr[0] = 0); assert.throws(() => arr[1] = 0); assert.throws(() => arr[2] = 0); assert.throws(() => arr[3] = 0); assert.throws(() => arr[4] = 0); });
// should timeout if next() isn't called in middleware it('should throw an error if cast is called, and not connected', function() { const app = new tibbar.default(); assert.throws(function() { app.cast('/') }); });
it('should throw an error if call is called, and not connected', () => { const app = new tibbar.default(); assert.throws(() => { app.call('/') }); });
function testPassNonPointerSync(declaration) { var writeString = lib.interface.writeString; assert(_.isFunction(writeString)); assert(writeString.function); assert.equal(writeString.function.toString(), declaration); assert.throws(function () { writeString(42); }); assert.throws(function () { writeString(); }); }