describe('Update', () => { test('It throws an exception if the id does not exists', async () => { const adapter = new MemorydbAdapter(); await adapter.connect(); await expect(adapter.update('items', { id: 'a' })).rejects.toThrow( 'Trying to update collection items with a non existing item with id a' ); }); });
test('If is an unknown operator throw an error', () => { const context = { a: 1, b: 2 }; const evaluator = new Evaluator(); const question = 'true ^^ false'; expect(() => evaluator.evaluate(question, context)).toThrow( 'Line 1: Unexpected token ^' ); });
test(`throws an error if SASL ${e.name} fails to authenticate`, async () => { const cluster = createCluster(e.wrongOpts(), saslBrokers()) producer = createProducer({ cluster, logger: newLogger() }) await expect(producer.connect()).rejects.toThrow(e.expectedErr) })
it('should load S3Adapter from direct passing', done => { spyOn(console, 'warn').and.callFake(() => {}); const s3Adapter = new S3Adapter('key', 'secret', 'bucket'); expect(() => { const adapter = loadAdapter(s3Adapter, FilesAdapter); expect(adapter).toBe(s3Adapter); }).not.toThrow(); done(); });
test('fail if file is missing', async () => { const filePath = path.resolve(context, 'assets/1000x600-missing.png') const queue = new AssetsQueue({ context, config: baseconfig }) await expect(queue.add(filePath, { srcset: false })).rejects.toThrow(/was not found/) })
describe('isValidName', () => { test('Validates names', () => { expect(runTest(isValidName, '89121')).toThrow(); expect(runTest(isValidName, '_zada')).toThrow(); expect(runTest(isValidName, 'AZopd azd a*$')).toThrow(); expect(runTest(isValidName, 'azda-azdazd')).toThrow(); expect(runTest(isValidName, '')).not.toThrow(); expect(runTest(isValidName, 'SomeValidName')).not.toThrow(); expect(runTest(isValidName, 'Some_azdazd_azdazd')).not.toThrow(); expect(runTest(isValidName, 'Som122e_azdazd_azdazd')).not.toThrow(); }); });
it('can throw on validateDeviceType when single invalid device type is set', done => { // Make query condition const where = { deviceType: 'osx', }; const validPushTypes = ['ios', 'android']; expect(function() { validatePushType(where, validPushTypes); }).toThrow(); done(); });
test('dynamic route with non-optional repeated segments', async () => { const api = await createPlugin() const collection = api.store.addCollection({ typeName: 'TestPost', route: '/path/:segments+' }) expect(() => collection.addNode({ segments: [] })).toThrow(TypeError, 'Expected "segments" to not be empty') })
test('itemQuery', async () => { const list = setup(); expect(await list.itemQuery({ where: { id: 0 } }, context)).toEqual({ name: 'a', email: 'a@example.com', index: 0, }); await expect(list.itemQuery({ where: { id: 4 } }, context)).rejects.toThrow(AccessDeniedError); });
test('throw if referencing missing collection', async () => { expect(initApp(({ addSchemaTypes }) => { addSchemaTypes(` type Track implements Node { album: MissingType } type MissingType implements Node { id: ID! } `) })).rejects.toThrow('Track.album') })
test('addToMongooseSchema()', () => { const impl = new Field('path', {}, args); expect(() => { impl.adapter.addToMongooseSchema(); }).toThrow(Error); });
test('addToMongooseSchema()', () => { const impl = new Field('path', {}, args); expect(() => { impl.adapter.addToMongooseSchema(); }).toThrow(Error); });