Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should do basic CRUD ops with relationships' , { shouldSupport: ['createWithRelationships'] }, async function(context : TestContext) {
const { storageManager } = await setupTest({ context })
const email = 'blub@bla.com', passwordHash = 'hashed!', expires = Date.now() + 1000 * 60 * 60 * 24
const { object: user } = await storageManager.collection('user').createObject(generateTestObject({ email, passwordHash, expires }))
expect(user).toMatchObject({
identifier: 'email:blub@bla.com',
passwordHash: 'hashed!',
isActive: false,
emails: [{
email: 'blub@bla.com',
isVerified: false,
isPrimary: true,
verificationCode: expect['objectContaining']({ code: 'bla' })
}]
})
await storageManager.collection('user').updateObjects({id: user.id}, {isActive: true})
expect(await storageManager.collection('user').findOneObject({id: user.id})).toMatchObject({
id: user.id,
identifier: user.identifier,
isActive: true
})
await storageManager.collection('user').deleteObjects({id: user.id})
expect(await storageManager.collection('user').findOneObject({id: user.id})).toBe(null)
})
it('handle a post call', () => {
const request = howard(config.url + '/post', {method: 'POST', body: {yo: 'hello my friend'}})
return expect(request).resolves.toMatchObject(expect.objectContaining({status: 200}));
})
it('should be able to find by $lte operator', async function(context : TestContext) {
const { storageManager } = await setupOperatorTest({
context,
fieldType: 'int'
})
await storageManager.collection('object').createObject({field: 1})
await storageManager.collection('object').createObject({field: 2})
await storageManager.collection('object').createObject({field: 3})
const results = await storageManager.collection('object').findObjects({field: {$lte: 2}})
expect(results).toContainEqual(expect.objectContaining({field: 1}))
expect(results).toContainEqual(expect.objectContaining({field: 2}))
expect(results).not.toContainEqual(expect.objectContaining({field: 3}))
})
placeholder: 'joeEmail',
operation: 'createObject',
collection: 'email',
args: {
address: 'joe@doe.com'
},
replace: [{
path: 'user',
placeholder: 'joe',
}]
},
])
expect(info).toEqual({
jane: {
object: expect.objectContaining({
id: expect.anything(),
displayName: 'Jane',
})
},
joe: {
object: expect.objectContaining({
id: expect.anything(),
displayName: 'Joe',
})
},
joeEmail: {
object: expect.objectContaining({
id: expect.anything(),
user: expect.anything(),
address: 'joe@doe.com'
})
it('should pass a clone of the record in the location state', () => {
const wrapper = shallow(
);
expect(wrapper.prop('to')).toEqual(
expect.objectContaining({
search: 'source=%7B%22foo%22%3A%22bar%22%7D',
})
);
});
});