How to use the expect.createSpy 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 swagger-api / swagger-ui / test / mocha / core / plugins / spec / actions.js View on Github external
it("should pass requestInterceptor/responseInterceptor to fn.execute", function(){
      // Given
      let configs = {
        requestInterceptor: createSpy(),
        responseInterceptor: createSpy()
      }
      const system = {
        fn: {
          buildRequest: createSpy(),
          execute: createSpy().andReturn(Promise.resolve())
        },
        specActions: {
          executeRequest: createSpy(),
          setMutatedRequest: createSpy(),
          setRequest: createSpy()
        },
        specSelectors: {
          spec: () => fromJS({}),
          parameterValues: () => fromJS({}),
          contentTypeValues: () => fromJS({}),
          url: () => fromJS({}),
          isOAS3: () => false
        },
        getConfigs: () => configs
      }
      // When
github redux-form / redux-form / src / __tests__ / reduxForm.spec.js View on Github external
it('should no resubmit if async submit is in progress', () => {
      const store = makeStore({
        testForm: {}
      })

      const Form = () => (
        <form>
          
          
        
      )

      const submitSpy = createSpy().andCall(() =&gt; new Promise(() =&gt; { /* Promise will never resolve */
      }))

      const Decorated = reduxForm({
        form: 'testForm',
        onSubmit: submitSpy
      })(Form)

      const dom = TestUtils.renderIntoDocument(
        
          
        
      )

      const stub = TestUtils.findRenderedComponentWithType(dom, Decorated)

      stub.submit()</form>
github swagger-api / swagger-editor / test / unit / plugins / editor / editor.js View on Github external
it("should be an event emitter", () => {
      // Given
      const fakeAce = new FakeAce()
      const spy = createSpy()
      fakeAce.on("foo", spy)

      // When
      fakeAce.emit("foo", "bar")

      // Then
      expect(spy.calls.length).toEqual(1)
      expect(spy.calls[0].arguments[0]).toEqual("bar")
    })
github swagger-api / swagger-editor / test / unit / layout.js View on Github external
it("should call the updateSpec function passed in as props with the contents of the file", () => {
        const fileContents = "This is my awesome file!"
        const props = {
          specActions: {
            updateSpec: expect.createSpy()
          }
        }
        global.FileReader.andReturn({
          readAsText: function () { this.onloadend() },
          result: fileContents
        })

        const editorLayout = new EditorLayout(props)

        editorLayout.onDrop(["accepted.file"])

        expect(props.specActions.updateSpec).toHaveBeenCalledWith(fileContents, "fileDrop")
      })
    })
github AlexGalays / kaiju / test / observable.js View on Github external
it('can have multiple subscribers', () => {

    let pushToObservable
    let activations = 0
    let deactivationFunction = expect.createSpy()
    const obs = Observable(add => {
      pushToObservable = add
      activations++
      return deactivationFunction
    })

    const subValues = []
    const unsub1 = obs.subscribe(x => subValues.push({ 1: x }))
    const unsub2 = obs.subscribe(x => subValues.push({ 2: x }))

    expect(activations).toBe(1)
    expect(deactivationFunction.calls.length).toBe(0)
    expect(subValues).toEqual([])

    pushToObservable(10)
    expect(subValues).toEqual([{ 1: 10 }, { 2: 10 }])
github swagger-api / swagger-editor / test / unit / mocks / ace.js View on Github external
this.renderer = {
      setShowGutter: createSpy(),
      setScrollMargin: createSpy()
    }
  }

  edit = createSpy().andReturn(this)

  acequire = createSpy().andCall((module) => {
    if(module == "ace/range") {
      return { Range }
    }
  })

  getSession = createSpy().andCall(() => {
    return this.session
  })

  setOption = createSpy().andCall((option, val) => {
   this.$options[option] = val
  })

  setOptions = createSpy().andCall((options) => {
    this.$options = {...this.$options, ...options}
  })

  getOption = createSpy().andCall((optionName) => {
    return this.$options[optionName]
  })

  setValue = createSpy().andCall((val, addToUndo=true) => {
github redux-form / redux-form / src / __tests__ / readField.spec.js View on Github external
const createRestorableSpy = (fn) => {
  return createSpy(fn, function restore() {
    this.calls = [];
  });
};
github redux-form / redux-form / src / __tests__ / readFields.spec.js View on Github external
const createRestorableSpy = (fn) => {
  return createSpy(fn, function restore() {
    this.calls = [];
  });
};
github jplayer / react-jPlayer / src / components / video / video.spec.jsx View on Github external
import Media from '../media/mediaContainer';
import componentSetup from '../../util/specHelpers/componentSetup.spec';

const events = {
  onAbort: expect.createSpy(),
  onCanPlay: expect.createSpy(),
  onCanPlayThrough: expect.createSpy(),
  onDurationChange: expect.createSpy(),
  onEmptied: expect.createSpy(),
  onEncrypted: expect.createSpy(),
  onEnded: expect.createSpy(),
  onError: expect.createSpy(),
  onLoadedData: expect.createSpy(),
  onLoadedMetadata: expect.createSpy(),
  onLoadStart: expect.createSpy(),
  onPause: expect.createSpy(),
  onPlay: expect.createSpy(),
  onPlaying: expect.createSpy(),
  onProgress: expect.createSpy(),
  onRateChange: expect.createSpy(),
  onSeeked: expect.createSpy(),
  onSeeking: expect.createSpy(),
  onStalled: expect.createSpy(),
  onSuspend: expect.createSpy(),
  onTimeUpdate: expect.createSpy(),
  onVolumeChange: expect.createSpy(),
  onWaiting: expect.createSpy(),
};

const setup = (props) => {
  const values = componentSetup(Video, {
    ...props,
github jplayer / react-jPlayer / src / components / audio / audio.spec.jsx View on Github external
import expect from 'expect';

import Audio from './audio';
import Media from '../media/mediaContainer';
import componentSetup from '../../util/specHelpers/componentSetup.spec';

const events = {
  onAbort: expect.createSpy(),
  onCanPlay: expect.createSpy(),
  onCanPlayThrough: expect.createSpy(),
  onDurationChange: expect.createSpy(),
  onEmptied: expect.createSpy(),
  onEncrypted: expect.createSpy(),
  onEnded: expect.createSpy(),
  onError: expect.createSpy(),
  onLoadedData: expect.createSpy(),
  onLoadedMetadata: expect.createSpy(),
  onLoadStart: expect.createSpy(),
  onPause: expect.createSpy(),
  onPlay: expect.createSpy(),
  onPlaying: expect.createSpy(),
  onProgress: expect.createSpy(),
  onRateChange: expect.createSpy(),
  onSeeked: expect.createSpy(),
  onSeeking: expect.createSpy(),
  onStalled: expect.createSpy(),
  onSuspend: expect.createSpy(),
  onTimeUpdate: expect.createSpy(),
  onVolumeChange: expect.createSpy(),

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