How to use the expect.assertions 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 legastero / stanza / test / live-connection.ts View on Github external
test('End to end', done => {
    expect.assertions(2);

    const client1 = stanza.createClient({
        jid: 'anon@anon.stanzajs.org'
    });
    const client2 = stanza.createClient({
        jid: 'anon@anon.stanzajs.org'
    });

    client1.on('session:started', async () => {
        const roster = await client1.getRoster();
        expect(roster.items).toStrictEqual([]);
        client1.sendPresence();

        client2.on('session:started', async () => {
            await client2.getRoster();
            client2.sendPresence();
github legastero / stanza / test / live-connection.ts View on Github external
test('Connect using BOSH', done => {
    expect.assertions(1);

    const client = stanza.createClient({
        jid: 'anon@anon.stanzajs.org',
        transports: {
            bosh: 'https://anon.stanzajs.org/http-bind'
        }
    });

    client.on('session:started', () => {
        client.disconnect();
        expect(true).toBe(true);
        done();
    });

    client.connect();
});
github legastero / stanza / test / jingle / processerrors.ts View on Github external
test('Test session-initiate with no contents fails', done => {
    expect.assertions(1);

    const jingle = new SessionManager({
        selfID
    });

    jingle.on('send', data => {
        expect(data).toEqual({
            error: {
                condition: 'bad-request',
                type: 'cancel'
            },
            id: '123',
            to: peerID,
            type: 'error'
        });
        done();
github legastero / stanza / test / jingle / reject.ts View on Github external
test('Return error for unknown transport-info action', done => {
    expect.assertions(1);

    const jingle = new SessionManager({
        selfID
    });

    const sess = new GenericSession({
        parent: jingle,
        peerID,
        sid: 'sid123'
    });
    jingle.addSession(sess);
    sess.state = 'active';

    jingle.on('send', data => {
        expect(data).toEqual({
            error: {
github legastero / stanza / test / jxt / streams.ts View on Github external
test('[Streams] Wrapped streams', done => {
    expect.assertions(4);

    const registry = setupRegistry();
    const parser = new StreamParser({
        registry,
        rootKey: 'stream',
        wrappedStream: true
    });

    parser.on('data', (data: ParsedData) => {
        if (data.event === 'stream-start') {
            expect(data.kind).toBe('stream');
        }
        if (data.event === 'stream-end') {
            expect(data.kind).toBe('stream');
        }
        if (!data.event) {
github legastero / stanza / test / jingle / basic.ts View on Github external
test('Test ending sessions for peer', done => {
    expect.assertions(2);

    const jingle = new SessionManager({
        selfID
    });

    const sess = new GenericSession({
        parent: jingle,
        peerID,
        sid: 'sid123'
    });
    jingle.addSession(sess);

    const sess2 = new GenericSession({
        parent: jingle,
        peerID,
        sid: 'sid124'
github legastero / stanza / test / jingle / basic.ts View on Github external
test('Prepare session', () => {
    expect.assertions(1);

    const jingle = new SessionManager({
        prepareSession: meta => {
            expect(meta).toBeTruthy();
            return new GenericSession(meta);
        },
        selfID
    });

    jingle.process({
        from: peerID,
        id: '123',
        jingle: {
            action: 'session-initiate',
            contents: [
                {
github legastero / stanza / test / jingle / session.ts View on Github external
test('Test cancelling a pending session', done => {
    expect.assertions(2);

    const jingle = new SessionManager({
        selfID
    });

    const sess = new StubSession({
        initiator: true,
        peerID
    });

    let started = false;
    jingle.on('send', data => {
        delete data.id;
        if (!started) {
            expect(data).toEqual({
                jingle: {
github marmelab / react-admin / packages / ra-core / src / controller / useListController.spec.tsx View on Github external
it('should take only last change in case of a burst of changes (case of inputs being currently edited)', () => {
            expect.assertions(2);

            const props = {
                ...defaultProps,
                children: fakeComponent,
            };

            const { getByLabelText, dispatch, reduxStore } = renderWithRedux(
                ,
                {
                    admin: {
                        resources: { posts: { list: { params: {} } } },
                    },
                }
            );
            const searchInput = getByLabelText('search');
github marmelab / react-admin / packages / ra-core / src / dataProvider / Query.spec.tsx View on Github external
it('supports declarative onSuccess side effects', async () => {
        expect.assertions(4);
        let dispatchSpy;
        const dataProvider = jest.fn();
        dataProvider.mockImplementationOnce(() =>
            Promise.resolve({ data: [{ id: 1, foo: 'bar' }], total: 42 })
        );

        let getByTestId;
        act(() => {
            const res = render(
                
                    
                        {({ store }) => {
                            dispatchSpy = jest.spyOn(store, 'dispatch');
                            return (

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 1 year ago

Package Health Score

88 / 100
Full package analysis