How to use the expect.spyOn 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 / parsers / raml / v1.0 / __tests__ / Parser.spec.js View on Github external
it('should work', () => {
      spyOn(__internals__, 'createSchema').andCall(v => [ v * 4 ])
      spyOn(__internals__, 'normalizeSchema').andCall(v => v / 2)
      spyOn(__internals__, 'addPathParameterToSequence').andCall((acc, v) => {
        acc.remaining = acc.remaining === 'def' ? '' : acc.remaining
        acc.sequence.push(v)
        return acc
      })

      spyOn(__internals__, 'createSimplePathnameParameter').andCall(s => OrderedMap({ [s]: s }))

      spyOn(__internals__, 'createPathnameEndpointFromParameter').andCall((r, c) => ({
        uri: r, comp: c
      }))

      spyOn(__internals__, 'createPathnameParameterFromSequenceAndFinalParam').andCall((s, c) => {
        return [].concat(s.map(v => v + 1), [ c ])
      })
github luckymarmot / API-Flow / src / models / __tests__ / Parameter.spec.js View on Github external
it('should call addDefaultFromParameterToSchema', () => {
      spyOn(__internals__, 'addDefaultFromParameterToSchema').andReturn({
        $schema: 'withConstraints'
      })

      const param = new Parameter()
      __internals__.getJSONSchemaFromSimpleParameter(param)

      expect(__internals__.addDefaultFromParameterToSchema).toHaveBeenCalled()
    })
github maildev / maildev / test / mailserver.js View on Github external
it('Error should be thrown, because listening to server did not work', function (done) {
      const maildev = new MailDev({
        silent: true,
        disableWeb: true
      })
      let spy = expect.createSpy()
      spy = expect.spyOn(process, 'emit')
      maildev.smtp.emit('error', { address: 'someAddress', port: 11111 })

      expect(spy).toHaveBeenCalled()
      spy.restore()
      maildev.close(done)
    })
  })
github luckymarmot / API-Flow / src / parsers / swagger / v2.0 / __tests__ / Parser.spec.js View on Github external
it('should call getContact', () => {
      spyOn(__internals__, 'getContact').andReturn(null)

      __internals__.getInfo()

      expect(__internals__.getContact).toHaveBeenCalled()
    })
github luckymarmot / API-Flow / src / serializers / paw / __tests__ / Serializer.spec.js View on Github external
it('should work with urlEncoded', () => {
      const pawReq = {}
      const store = new Store()
      const params = [ 123, 321, 234, 432 ]
      const context = new Context()

      spyOn(__internals__, 'convertReferenceOrParameterToDsEntry').andReturn(123)
      spyOn(__internals__, 'addEntryToRecordParameterArray').andReturn([ 123, 234, 345, 456, 567 ])

      spyOn(__internals__, 'isContextWithUrlEncoded').andReturn(true)
      spyOn(__internals__, 'isContextWithMultiPart').andReturn(false)

      spyOn(__internals__, 'createUrlEncodedBodyDV').andReturn(678)
      spyOn(__internals__, 'wrapDV').andReturn('test')

      const expected = {
        body: 'test'
      }

      const actual = __internals__.setFormDataBody(pawReq, store, params, context)

      expect(__internals__.convertReferenceOrParameterToDsEntry.calls.length).toEqual(4)
      expect(__internals__.addEntryToRecordParameterArray.calls.length).toEqual(4)
      expect(__internals__.isContextWithUrlEncoded).toHaveBeenCalled()
      expect(__internals__.isContextWithMultiPart).toHaveBeenCalled()
      expect(__internals__.createUrlEncodedBodyDV).toHaveBeenCalled()
      expect(__internals__.wrapDV).toHaveBeenCalled()
      expect(actual).toEqual(expected)
    })
github luckymarmot / API-Flow / src / parsers / postman / v2.0 / __tests__ / Parser.spec.js View on Github external
it('should work', () => {
      spyOn(__internals__, 'extractAuthFromPostmanAuth')
        .andCall(v => v % 2 ? { key: v, value: v } : null)

      const inputs = [
        [],
        [ null, {}, { request: {} }, { request: '123123' } ],
        [ { request: { auth: 123 } }, { request: { auth: 234 } }, { request: { auth: 345 } } ]
      ]
      const expected = [
        { key: 'auth', value: OrderedMap() },
        { key: 'auth', value: OrderedMap() },
        { key: 'auth', value: OrderedMap({
          '123': 123,
          '345': 345
        }) }
      ]
      const actual = inputs.map(input => __internals__.extractAuthTypedStore(input))
github luckymarmot / API-Flow / src / serializers / swagger / v2.0 / __tests__ / Serializer.spec.js View on Github external
it('should work', () => {
      spyOn(__internals__, 'convertBasicAuth').andReturn(123)
      spyOn(__internals__, 'convertApiKeyAuth').andReturn(234)
      spyOn(__internals__, 'convertOAuth2Auth').andReturn(345)

      const inputs = [
        new Auth.Basic(),
        new Auth.ApiKey(),
        new Auth.OAuth2(),
        new Auth.Hawk()
      ]
      const expected = [
        123, 234, 345, null
      ]
      const actual = inputs.map(input => __internals__.convertAuthToSecurityRequirementEntry(input))
      expect(actual).toEqual(expected)
    })
  })
github Kitware / HPCCloud / test / redux / aws.js View on Github external
function setSpy(target, method, data) {
  spyOn(target, method).andReturn(Promise.resolve({ data }));
}
github dwightjack / vue-types / test / index.spec.js View on Github external
beforeEach(() => {
      spy = spyOn(VueTypes, 'custom').andCallThrough()
    })
github luckymarmot / API-Flow / src / parsers / raml / v1.0 / __tests__ / Parser.spec.js View on Github external
spyOn(__internals__, 'convertObjectTypeDeclaration').andReturn([
        { a: 4 }, { b: 5 }, { c: 6 }
      ])
      spyOn(__internals__, 'convertArrayTypeDeclaration').andReturn([
        { a: 7 }, { b: 8 }, { c: 9 }
      ])
      spyOn(__internals__, 'convertUnionTypeDeclaration').andReturn([
        { a: 10 }, { b: 11 }, { c: 12 }
      ])
      spyOn(__internals__, 'convertStringTypeDeclaration').andReturn([
        { a: 13 }, { b: 14 }, { c: 15 }
      ])
      spyOn(__internals__, 'convertNumberTypeDeclaration').andReturn([
        { a: 16 }, { b: 17 }, { c: 18 }
      ])
      spyOn(__internals__, 'convertBooleanTypeDeclaration').andReturn([
        { a: 19 }, { b: 20 }, { c: 21 }
      ])
      spyOn(__internals__, 'convertDateOnlyTypeDeclaration').andReturn([
        { a: 22 }, { b: 23 }, { c: 24 }
      ])
      spyOn(__internals__, 'convertTimeOnlyTypeDeclaration').andReturn([
        { a: 25 }, { b: 26 }, { c: 27 }
      ])
      spyOn(__internals__, 'convertDateTimeOnlyTypeDeclaration').andReturn([
        { a: 28 }, { b: 29 }, { c: 30 }
      ])
      spyOn(__internals__, 'convertDateTimeTypeDeclaration').andReturn([
        { a: 31 }, { b: 32 }, { c: 33 }
      ])
      spyOn(__internals__, 'convertFileTypeDeclaration').andReturn([
        { a: 34 }, { b: 35 }, { c: 36 }

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