forked from swagger-api/swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: non-typesafe spec selector (via swagger-api#5121)
* add failing tests * fix things
- Loading branch information
Showing
4 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* eslint-env mocha */ | ||
import expect, { createSpy } from "expect" | ||
import { Map, fromJS } from "immutable" | ||
import { | ||
definitions | ||
} from "corePlugins/oas3/spec-extensions/wrap-selectors" | ||
|
||
describe("oas3 plugin - spec extensions - wrapSelectors", function(){ | ||
|
||
describe("definitions", function(){ | ||
it("should return definitions by default", function () { | ||
|
||
// Given | ||
const spec = fromJS({ | ||
openapi: "3.0.0", | ||
components: { | ||
schemas: { | ||
a: { | ||
type: "string" | ||
}, | ||
b: { | ||
type: "string" | ||
} | ||
} | ||
} | ||
}) | ||
|
||
const system = { | ||
getSystem: () => system, | ||
specSelectors: { | ||
specJson: () => spec, | ||
} | ||
} | ||
|
||
// When | ||
let res = definitions(() => null, system)(fromJS({ | ||
json: 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({ | ||
openapi: "3.0.0" | ||
}) | ||
|
||
const system = { | ||
getSystem: () => system, | ||
specSelectors: { | ||
specJson: () => spec, | ||
} | ||
} | ||
|
||
// When | ||
let res = definitions(() => null, system)(fromJS({ | ||
json: spec | ||
})) | ||
|
||
// Then | ||
expect(res.toJS()).toEqual({}) | ||
}) | ||
it("should return an empty Map when given non-object definitions", function () { | ||
|
||
// Given | ||
const spec = fromJS({ | ||
openapi: "3.0.0", | ||
components: { | ||
schemas: "..." | ||
} | ||
}) | ||
|
||
const system = { | ||
getSystem: () => system, | ||
specSelectors: { | ||
specJson: () => spec, | ||
} | ||
} | ||
|
||
// When | ||
let res = definitions(() => null, system)(fromJS({ | ||
json: spec | ||
})) | ||
|
||
// Then | ||
expect(res.toJS()).toEqual({}) | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters