Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 ])
})
it('should call addDefaultFromParameterToSchema', () => {
spyOn(__internals__, 'addDefaultFromParameterToSchema').andReturn({
$schema: 'withConstraints'
})
const param = new Parameter()
__internals__.getJSONSchemaFromSimpleParameter(param)
expect(__internals__.addDefaultFromParameterToSchema).toHaveBeenCalled()
})
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)
})
})
it('should call getContact', () => {
spyOn(__internals__, 'getContact').andReturn(null)
__internals__.getInfo()
expect(__internals__.getContact).toHaveBeenCalled()
})
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)
})
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))
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)
})
})
function setSpy(target, method, data) {
spyOn(target, method).andReturn(Promise.resolve({ data }));
}
beforeEach(() => {
spy = spyOn(VueTypes, 'custom').andCallThrough()
})
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 }