How to use the expect 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 luckymarmot / API-Flow / src / models / __tests__ / Parameter.spec.js View on Github external
spyOn(__internals__, 'isReferenceParameter').andCall(({ reference }) => !!reference)
      spyOn(__internals__, 'getJSONSchemaFromReferenceParameter')
        .andCall(({ reference }) => reference)

      const inputs = [
        [ { simple: 123 }, false ],
        [ { sequence: 234 }, false ],
        [ { array: 345 }, false ],
        [ { reference: 456 }, false ],
        [ { other: 567 }, false ]
      ]
      const expected = [
        123, 234, 345, 456, {}
      ]
      const actual = inputs.map(input => __internals__.getRawJSONSchema(...input))
      expect(actual).toEqual(expected)
    })
    /* eslint-enable max-statements */
github mgcrea / node-xlsx / test / specs / helper.spec.js View on Github external
it('should display data in percentage format with 2-decimal precision', () => {
        const primitive = [[{t: 'n', z: 4, f: '=SUM(2:2)'}]];

        const sheet = buildSheetFromMatrix(primitive);
        expect(sheet.A1.t).toBe('n');
        expect(sheet.A1.f).toBe('=SUM(2:2)');
        expect(sheet.A1.z).toBe('#,##0.00');
      });
    });
github RhoInc / Webcharts / test / utilities.js View on Github external
it('Computes max', () => {
            const max = summarize(mixedArray, 'max');
            expect(max).toBe(20);
        });
        it('Computes mean', () => {
github mikechabot / redux-entity / test / unit / test-reducer.js View on Github external
it('should return the defined state', () => {
                const state = {foo: 'bar'};
                expect(reducer(state, {type: null})).toEqual(state);
            });
        });
github jhorneman / choba-engine / test / expressions / sceneExpressions.spec.js View on Github external
it('deals with expressions returning scene parts', () => {
        const sceneText = 'YAY!';
        const nextSceneId = 'sceneD';
        const sceneDesc = {
            content: ['seq',
                ['text', sceneText],
                buildGotoOptionExpression(nextSceneId)
            ]
        };
        context.scenes[sceneId] = sceneDesc;
        reportError = expect.spyOn(context, 'reportError');
        let { scene, dynamicState: newDynamicState } = evaluateScene(sceneId, dynamicState, context);
        expect(reportError).toNotHaveBeenCalled();
        expect(scene.text).toEqual(sceneText);
        expect(scene.options).toEqual([
            {text: 'Go to ' + nextSceneId, action: 'goto', parameters: [nextSceneId]}
        ]);
        expect(scene.desc).toEqual(sceneDesc);
        expect(newDynamicState).toBe(dynamicState);
    });
});
github luckymarmot / API-Flow / src / models / __tests__ / Parameter.spec.js View on Github external
it('should call inferType if type if not standard', () => {
      const param = new Parameter({ type: 'double' })
      const schema = {}

      spyOn(__internals__, 'inferType').andReturn('number')

      const expected = {
        type: 'number'
      }

      const actual = __internals__.addTypeFromParameterToSchema(param, schema)

      expect(__internals__.inferType).toHaveBeenCalled()
      expect(actual).toEqual(expected)
    })
github swagger-api / swagger-editor / test / unit / plugins / validate-semantic / security.js View on Github external
.then(system => {
        const allErrors = system.errSelectors.allErrors().toJS()
        expect(allErrors.length).toEqual(1)
        const firstError = allErrors[0]
        expect(firstError.path).toEqual(["paths", "/", "get", "security", "0", "0"])
        expect(firstError.message).toMatch("Security scope definition write:pets could not be resolved")
      })
  })
github zalmoxisus / redux-devtools-instrument / test / instrument.spec.js View on Github external
let storeWithBug = createStore(
        counterWithBug,
        instrument(undefined, { maxAge: 3, shouldCatchErrors: true })
      );
      let liftedStoreWithBug = storeWithBug.liftedStore;

      storeWithBug.dispatch({ type: 'DECREMENT' });
      storeWithBug.dispatch({ type: 'DECREMENT' });
      storeWithBug.dispatch({ type: 'DECREMENT' });
      storeWithBug.dispatch({ type: 'DECREMENT' });

      let liftedStoreState = liftedStoreWithBug.getState();
      let currentComputedState = liftedStoreState.computedStates[liftedStoreState.currentStateIndex];
      expect(liftedStoreState.currentStateIndex).toBe(4);
      expect(currentComputedState.state).toBe(0);
      expect(currentComputedState.error).toExist();

      spy.restore();
    });
github angular-redux / ng-redux / test / components / storeWrapper.spec.js View on Github external
const ngReduxStore = mockStore((action) => {
      dispatches++;
      expect(action.type).toEqual('@@NGREDUX_PASSTHROUGH');

      if (action.payload) {
        expect(action.payload).toEqual('TEST DISPATCH');
      }
    });
github jplayer / react-jPlayer / src / components / media / mediaContainer.spec.jsx View on Github external
it('pauses the media when paused', () => {
        const { store } = setup(jPlayers);

        store.dispatch(pause(id));

        expect(mockCurrentMedia.pause).toHaveBeenCalled();
      });

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