How to use the expect.objectContaining function in expect

To help you get started, we’ve selected a few expect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WorldBrain / storex / ts / index.tests.ts View on Github external
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)
    })
github samrocksc / howard / test / index.js View on Github external
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}));
  })
github WorldBrain / storex / ts / index.tests.ts View on Github external
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}))
        })
github WorldBrain / storex / ts / index.tests.ts View on Github external
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'
                    })
github marmelab / react-admin / packages / ra-ui-materialui / src / button / CloneButton.spec.tsx View on Github external
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',
            })
        );
    });
});

expect

This package exports the `expect` function used in [Jest](https://jestjs.io/). You can find its documentation [on Jest's website](https://jestjs.io/docs/expect).

MIT
Latest version published 8 months ago

Package Health Score

93 / 100
Full package analysis