beforeEach(() => { var cache = require.cache; projectModuleIds.forEach(id => delete cache[id]); jasmine.clock().install(); });
/** * Update all of the TODO items with the same object. * the data to be updated. Used to mark all TODOs as completed. * @param {object} updates An object literal containing only the data to be * updated. */ function updateAll(updates) { _todos.forEach(function(todo) { update(todo.id, updates); }); }
describe('root constant', () => { allConstants.forEach((value, key) => { test(`contains ${key} constants`, () => { expect(root).toMatchObject(value); }); }); test('length is accurate', () => { const expectedTotal = allConstants.reduce( (sum, constants) => sum + Object.keys(constants).length, 0, ); expect(Object.keys(root).length).toEqual(expectedTotal); }); });
/** * Delete all the completed TODO items. */ function destroyCompleted() { _todos.forEach(function(todo) { if (todo.complete) { destroy(todo.id) } }); }
describe('<%= duckName %> API', () => { afterEach(() => { nock.cleanAll() }) it('fetches example things', () => { const expectedThings = [ { 'id': 1, 'title': 'Thing #1', 'description': 'This thing is super cool' }, { 'id': 2, 'title': 'Thing #2', 'description': 'This thing is super super cool' }, { 'id': 3, 'title': 'Thing #3', 'description': 'This thing is super mega cool' } ] nock(`http://${API_HOSTNAME}`) .get('/example') .reply(HTTP_200, expectedThings) return api.fetchExample() .then((payload) => { expect(payload).toBeInstanceOf(List) // eslint-disable-next-line max-nested-callbacks payload.forEach((thing, idx) => { expect(thing).toEqual(expectedThings[idx]) }) }) }) })