Skip to content

Commit 4dcc86d

Browse files
committed
add tests
1 parent e83e325 commit 4dcc86d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/oas3/execute/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,5 +484,30 @@ describe('buildRequest - OpenAPI Specification 3.0', function () {
484484

485485
expect(res).toEqual('https://petstore.com')
486486
})
487+
it('should fall back to contextUrls if no servers are provided', function () {
488+
const spec = {
489+
openapi: '3.0.0'
490+
}
491+
492+
const res = baseUrl({
493+
spec,
494+
server: 'http://some-invalid-server.com/',
495+
contextUrl: 'http://google.com/'
496+
})
497+
498+
expect(res).toEqual('http://google.com')
499+
})
500+
it('should return an empty string if no servers or contextUrl are provided', function () {
501+
const spec = {
502+
openapi: '3.0.0'
503+
}
504+
505+
const res = baseUrl({
506+
spec,
507+
server: 'http://some-invalid-server.com/'
508+
})
509+
510+
expect(res).toEqual('')
511+
})
487512
})
488513
})

0 commit comments

Comments
 (0)