fix: non-typesafe spec selector (via #5121)
* add failing tests * fix things
This commit is contained in:
@@ -3,6 +3,7 @@ import expect from "expect"
|
||||
import { fromJS } from "immutable"
|
||||
import { fromJSOrdered } from "core/utils"
|
||||
import {
|
||||
definitions,
|
||||
parameterValues,
|
||||
contentTypeValues,
|
||||
operationScheme,
|
||||
@@ -21,6 +22,70 @@ import {
|
||||
|
||||
describe("spec plugin - selectors", function(){
|
||||
|
||||
describe("definitions", function(){
|
||||
it("should return definitions by default", function(){
|
||||
|
||||
// Given
|
||||
const spec = fromJS({
|
||||
json: {
|
||||
swagger: "2.0",
|
||||
definitions: {
|
||||
a: {
|
||||
type: "string"
|
||||
},
|
||||
b: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// When
|
||||
let res = definitions(spec)
|
||||
|
||||
// Then
|
||||
expect(res.toJS()).toEqual({
|
||||
a: {
|
||||
type: "string"
|
||||
},
|
||||
b: {
|
||||
type: "string"
|
||||
}
|
||||
})
|
||||
})
|
||||
it("should return an empty Map when missing definitions", function(){
|
||||
|
||||
// Given
|
||||
const spec = fromJS({
|
||||
json: {
|
||||
swagger: "2.0"
|
||||
}
|
||||
})
|
||||
|
||||
// When
|
||||
let res = definitions(spec)
|
||||
|
||||
// Then
|
||||
expect(res.toJS()).toEqual({})
|
||||
})
|
||||
it("should return an empty Map when given non-object definitions", function(){
|
||||
|
||||
// Given
|
||||
const spec = fromJS({
|
||||
json: {
|
||||
swagger: "2.0",
|
||||
definitions: "..."
|
||||
}
|
||||
})
|
||||
|
||||
// When
|
||||
let res = definitions(spec)
|
||||
|
||||
// Then
|
||||
expect(res.toJS()).toEqual({})
|
||||
})
|
||||
})
|
||||
|
||||
describe("parameterValue", function(){
|
||||
|
||||
it("should return Map({}) if no path found", function(){
|
||||
|
||||
Reference in New Issue
Block a user