assert.fail('No error thrown'); } catch (err) { assert.deepStrictEqual(err, new Error('Something bad happened.'));
tom.test(".explain: file doesn't exist", function () { return jsdoc.explain({ files: 'sdfafafirifrj' }) .then(function () { a.fail('should not reach here') }) .catch(function (err) { a.strictEqual(err.name, 'JSDOC_ERROR') }) })
it('should cancel a delayed promise', () => { const promise = Aigle.delay(DELAY); promise.cancel(); return promise .then(assert.fail) .catch((error) => assert.ok(error instanceof CancellationError)); });
function makeQueueEntry(entryClass, { key, versionId, contentMd5 }) { if (entryClass === 'ObjectQueueEntry') { return makeObjectQueueEntry({ key, versionId, contentMd5 }); } if (entryClass === 'ActionQueueEntry') { return makeActionQueueEntry({ key, versionId, contentMd5 }); } return assert.fail(`bad class ${entryClass}`); }
_getSpinnerMessage(selectedOptions) { switch (selectedOptions.action) { case MANAGE_ACTION.REMOVE: return NodeTranslationService.getMessage(MESSAGES.REMOVING); case MANAGE_ACTION.RENAME: return NodeTranslationService.getMessage(MESSAGES.RENAMING); case MANAGE_ACTION.LIST: return NodeTranslationService.getMessage(MESSAGES.LISTING); case MANAGE_ACTION.INFO: return NodeTranslationService.getMessage(MESSAGES.INFO, selectedOptions.authId); } assert.fail(NodeTranslationService.getMessage(ERRORS.UNKNOWN_ACTION)); }
it('should catch an error', () => { const error = new Error('error'); Aigle.mixin({ countBy: _.countBy }, { override: true }); return Aigle.countBy([0, 1, 2], (n) => { return n % 2 ? Aigle.delay(DELAY, n) : Aigle.reject(error); }) .then(assert.fail) .catch((err) => assert.strictEqual(err, error)); });
process.on('exit', function () { if (!exports.globalCheck) return; var leaked = leakedGlobals(); if (leaked.length > 0) { assert.fail('Unexpected global(s) found: ' + leaked.join(', ')); } });
tom.test('.explain: invalid doclet syntax', function () { const input = path.resolve(__dirname, 'fixture', 'buggy', 'bad-doclet-syntax.js') return jsdoc.explain({ files: input }) .then(function () { a.fail('should not reach here') }) .catch(function (err) { a.strictEqual(err.name, 'JSDOC_ERROR') }) })
it('Should throw an error without projectId', async () => { process.env.GOOGLE_PROJECT_ID = ''; try { await tools.runAsync('node metrics-quickstart.js'); assert.fail('Did not throw an error.'); } catch (err) { assert.ok(err.message.includes('Unable to proceed without a Project ID')); } });
it('should call a canceling function', () => { let called = false; const promise = new Aigle((resolve, reject, onCancel) => { setTimeout(resolve, DELAY); onCancel(() => (called = true)); }); promise.cancel(); return promise.then(assert.fail).catch((error) => { assert.ok(called); assert.ok(error instanceof CancellationError); assert.strictEqual(error.message, 'late cancellation observer'); }); });
it('should execute a reject function with promise object', (done) => { const error = new Error('error'); const promise = new Aigle((resolve, reject) => reject(error)); new Aigle((resolve) => resolve(promise)).then(assert.fail).catch((err) => { assert.strictEqual(err, error); done(); }); });
it('should catch an error', () => { let called = 0; const error = new Error('error'); return new Aigle((resolve, reject, onCancel) => { setTimeout(reject, DELAY, error); onCancel(() => called++); }) .then(assert.fail) .catch((err) => { assert.strictEqual(called, 0); assert.strictEqual(err, error); }); });
it('should throw an TypeError if canceling function is not function', () => { return new Aigle((resolve, reject, onCancel) => { onCancel(1); }) .then(assert.fail) .catch(TypeError, assert.ok); });
it('should execute with object and catch an error', () => { const error = new Error('error'); Aigle.mixin({ countBy: _.countBy }, { override: true }); return Aigle.countBy({ a: 0, b: 1, c: 2 }, (n) => { return n % 2 ? Aigle.delay(DELAY, n) : Aigle.reject(error); }) .then(assert.fail) .catch((err) => assert.strictEqual(err, error)); });
it('Should throw an error without projectId', async () => { process.env.GOOGLE_PROJECT_ID = ''; try { await tools.runAsync('node metrics-quickstart.js'); assert.fail('Did not throw an error.'); } catch (err) { assert.ok(err.message.includes('Unable to proceed without a Project ID')); } });