Compare commits

..
51 Commits
Author SHA1 Message Date
kyle 774a06606d Merge pull request #3699 from shockey/v/3.2.2
v3.2.2
2017-09-23 14:43:44 -07:00
Kyle Shockey 2d10a740af Rebuild with changes from #3702 2017-09-23 13:09:08 -07:00
Kyle Shockey 45e7a54182 Merge branch 'master' of github.com:swagger-api/swagger-ui into v/3.2.2 2017-09-23 12:58:06 -07:00
kyle 9e418ad68b Merge pull request #3702 from owenconti/bug/3511-query-formData-parameters
Fixes #3511 - 2nd attempt - Query & formData parameters together
2017-09-23 12:57:35 -07:00
Kyle Shockey de61dccff0 Revert "Revert "Merge pull request #3516 from owenconti/bug/3511-query-formData-parameters""
This reverts commit beeb6b608e.
2017-09-23 12:54:17 -07:00
Owen Conti fd00a0489a Remove shouldComponentUpdate from parameter-row component. It will be put back in eventually as part of the performance optimizations once the parameter components are converted to the smart/dumb approach. 2017-09-23 13:10:09 -06:00
Kyle Shockey beeb6b608e Revert "Merge pull request #3516 from owenconti/bug/3511-query-formData-parameters"
This reverts commit 6a7e9d2e88, reversing
changes made to eb01beedfa.
2017-09-23 10:51:32 -07:00
Kyle Shockey c8a9ddbf94 v3.2.2 2017-09-23 00:02:10 -07:00
kyle 1de6010629 Merge pull request #3666 from AlexanderVangelov/master
OAuth2 authorizationUrl allow extra query parameters ('&' vs '?')
2017-09-22 20:49:21 -07:00
kyle b6eb23217f Merge branch 'master' into master 2017-09-22 20:45:07 -07:00
kyle a3f923eec7 Merge pull request #3698 from shockey/heldersepu-master
Heldersepu master
2017-09-22 20:16:08 -07:00
Kyle Shockey 6b59707af1 Fix tests 2017-09-22 19:50:36 -07:00
kyle 827bcd2f36 Merge branch 'master' into master 2017-09-22 19:50:19 -07:00
kyle 6a7e9d2e88 Merge pull request #3516 from owenconti/bug/3511-query-formData-parameters
Fixes #3511 - Query & formData parameters together
2017-09-22 19:27:31 -07:00
HelderSepu e08f31d674 Add UnitTests for validateDateTime & validateGuid 2017-09-22 21:37:33 -04:00
HelderSepu 7d9b56255c Correction to the validateDateTime 2017-09-22 17:44:01 -04:00
Helder Sepulveda b2abf769de Merge branch 'master' into master 2017-09-22 13:04:09 -04:00
HelderSepu 11768b16bf Correct IF for validateDateTime & validateGuid 2017-09-22 11:30:07 -04:00
kyle 54a2d402c6 Merge branch 'master' into master 2017-09-21 00:15:41 -07:00
Owen Conti a1758da87c Merge branch 'master' into bug/3511-query-formData-parameters 2017-09-20 22:37:43 -06:00
kyle eb01beedfa Merge pull request #3691 from shockey/bug/3638-61338ref-in-examples
Remove $$ref values from response examples
2017-09-20 17:42:03 -07:00
kyle deebe1f840 Merge branch 'master' into bug/3638-61338ref-in-examples 2017-09-20 17:36:57 -07:00
Kyle Shockey 69941a6d9a Remove $$ref values from response examples 2017-09-20 17:34:23 -07:00
kyle 6a8f821901 Merge pull request #3690 from shockey/bug/3636-tag-description-markdown
Display Tag descriptions as Markdown
2017-09-20 17:01:45 -07:00
Kyle Shockey b0a580bdc1 Display Tag descriptions as Markdown 2017-09-20 16:55:45 -07:00
Alexander Vangelov 696bdcf961 Merge branch 'master' into master 2017-09-20 13:11:53 -04:00
kyle 6d67c6dabe Merge pull request #3676 from owenconti/bug/3633-primitive-titles
Fixes #3633 - PrimitiveModel titles
2017-09-19 20:17:49 -07:00
kyle 69799b0975 Merge branch 'master' into bug/3633-primitive-titles 2017-09-19 20:14:00 -07:00
HelderSepu 85b7b7241d Add validateDateTime & validateGuid
Initial work to tacke some of the missing validation (Issue #993)
2017-09-19 14:31:27 -04:00
HelderSepu bd6e482df2 Merge remote-tracking branch 'refs/remotes/swagger-api/master' 2017-09-19 13:37:04 -04:00
Owen Conti 7ef8a7ddc7 Merge branch 'master' of github.com:swagger-api/swagger-ui into bug/3511-query-formData-parameters
# Conflicts:
#	src/core/components/parameter-row.jsx
#	src/core/plugins/spec/actions.js
2017-09-18 16:59:08 -06:00
Kyle aa9e008f0b Merge pull request #3679 from swagger-api/shockey-readme-updates
README: npm module clarifications
2017-09-18 15:12:25 -07:00
Kyle b43ac6da44 Update README.md 2017-09-18 13:38:11 -07:00
Kyle cb3e1ed78c Update README.md 2017-09-18 13:36:07 -07:00
Owen Conti 44ece46cd3 Fixes #3633
Make sure PrimitiveModel uses the schema's title first and then falls back to the passed-in `name` property. Added enzyme test for functionality.
2017-09-17 09:49:13 -06:00
Owen Conti f63f022e0c Remove .only from utils test 2017-09-17 09:48:26 -06:00
Owen Conti b855c25406 Slightly increase size available for property names. Change units to em and add a margin to separate the property name from the property type. 2017-09-17 09:48:03 -06:00
Owen Conti 08282205aa Fix property key: value alignment in array-model 2017-09-17 09:45:33 -06:00
Alexander Vangelov 90fa7065f8 Merge branch 'master' into master 2017-09-16 11:24:36 -04:00
AlexVangelov c1abdfb1c4 follow lowercase naming convention in tests 2017-09-15 21:04:38 -04:00
AlexVangelov 5bf6d2ff0b Merge branches 'master' and 'master' of github.com:AlexanderVangelov/swagger-ui 2017-09-15 20:53:52 -04:00
AlexVangelov 4172e33e04 satisfy project lint rules 2017-09-15 20:52:55 -04:00
Alexander Vangelov 34e8fffb65 Merge branch 'master' into master 2017-09-15 20:40:46 -04:00
AlexVangelov 9b1a6141df OAuth2 authorizationUrl with extra query parameters (should include double '?') 2017-09-15 15:57:41 -04:00
Owen Conti 5d7d20ec5e Merge branch 'master' into bug/3511-query-formData-parameters 2017-08-03 19:30:50 -06:00
Owen Conti 7a694e287a Change name format to in.name and update tests 2017-08-03 19:29:49 -06:00
Owen Conti 17e99428c7 Merge branch 'bug/3511-query-formData-parameters' of github.com:owenconti/swagger-ui into bug/3511-query-formData-parameters 2017-08-03 07:14:15 -06:00
Owen Conti ce8adb91a5 Fix failing selector test 2017-08-03 07:14:03 -06:00
Owen Conti 053d032e94 Merge branch 'master' into bug/3511-query-formData-parameters 2017-08-02 22:37:49 -06:00
Owen Conti 51016c33f4 Attach in value to parameters map so parameters with the same name from different in types do not override each other. 2017-08-02 22:37:31 -06:00
Owen Conti fdb0d13089 Fixes #3511 - Update changeParameter calls to accept in value to identify parameters based on name plus in value 2017-08-02 22:07:48 -06:00
25 changed files with 197 additions and 50 deletions
+4 -4
View File
@@ -10,10 +10,10 @@
As a brand new version, written from the ground up, there are some known issues and unimplemented features. Check out the [Known Issues](#known-issues) section for more details.
This repo publishes to two different NPM packages:
This repository publishes to two different NPM modules:
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is intended for use as a node module.
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) comes pre-bundled with all dependencies and can be incorporated directly in a webapp.
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is a traditional npm module intended for use in JavaScript web application projects that are capable of resolving dependencies (via Webpack, Browserify, etc).
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) is a dependency-free module that includes everything you need to serve Swagger-UI in a server-side project, or a web project that can't resolve npm module dependencies.
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
@@ -22,7 +22,7 @@ The OpenAPI Specification has undergone 5 revisions since initial creation in 20
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ | ------------ | -------------------------- | -----
3.2.1 | 2017-09-15 | 2.0, 3.0 | [tag v3.2.1](https://github.com/swagger-api/swagger-ui/tree/v3.2.1)
3.2.2 | 2017-09-22 | 2.0, 3.0 | [tag v3.2.2](https://github.com/swagger-api/swagger-ui/tree/v3.2.2)
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10)
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5)
+11 -11
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AAwjMA;;;;;;AA65DA;;;;;;;;;;;;;;;;;;;;;;;;;;AAs9TA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AAm/pBA;;;;;AAu5QA;;;;;AAynBA;AAi0CA;;;;;;AAq/YA;;;;;;AAojaA;AA8lvBA","sourceRoot":""}
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;;;;;AA4kMA;;;;;;AA65DA;;;;;;;;;;;;;;;;;;;;;;;;;;AAq9TA;;;;;;;;;;;;;;AAs8JA;;;;;;;;;AAo/pBA;;;;;AAk6QA;;;;;AAynBA;AAi0CA;;;;;;AAq/YA;;;;;;AAojaA;AA8lvBA","sourceRoot":""}
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAmxeA","sourceRoot":""}
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AAkzeA","sourceRoot":""}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "3.2.1",
"version": "3.2.2",
"main": "dist/swagger-ui.js",
"repository": "git@github.com:swagger-api/swagger-ui.git",
"contributors": [
@@ -77,7 +77,7 @@
"scroll-to-element": "^2.0.0",
"serialize-error": "2.0.0",
"shallowequal": "0.2.2",
"swagger-client": "3.1.1",
"swagger-client": "^3.1.2",
"url-parse": "^1.1.8",
"whatwg-fetch": "0.11.1",
"worker-loader": "^0.7.1",
+1 -1
View File
@@ -41,7 +41,7 @@ export default class ArrayModel extends Component {
{
properties.size ? <span>
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
<br />{ `${key}:`}{ String(v) }</span>)
<br />{ key }: { String(v) }</span>)
}<br /></span>
: null
}
+2 -1
View File
@@ -36,6 +36,7 @@ export default class Operations extends React.Component {
const Operation = getComponent("operation")
const Collapse = getComponent("Collapse")
const Markdown = getComponent("Markdown")
let showSummary = layoutSelectors.showSummary()
let {
@@ -89,7 +90,7 @@ export default class Operations extends React.Component {
</a>
{ !tagDescription ? null :
<small>
{ tagDescription }
<Markdown source={tagDescription} />
</small>
}
+2 -2
View File
@@ -47,7 +47,7 @@ export default class ParamBody extends PureComponent {
updateValues = (props) => {
let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : {}
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name"), param.get("in")) : {}
let isXml = /xml/i.test(consumesValue)
let isJson = /json/i.test(consumesValue)
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value")
@@ -107,7 +107,7 @@ export default class ParamBody extends PureComponent {
const HighlightCode = getComponent("highlightCode")
const ContentType = getComponent("contentType")
// for domains where specSelectors not passed
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : param
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name"), param.get("in")) : param
let errors = parameter.get("errors", List())
let consumesValue = specSelectors.contentTypeValues(pathMethod).get("requestContentType")
let consumes = this.props.consumes && this.props.consumes.size ? this.props.consumes : ParamBody.defaultProp.consumes
+2 -2
View File
@@ -19,7 +19,7 @@ export default class ParameterRow extends Component {
let { specSelectors, pathMethod, param } = props
let defaultValue = param.get("default")
let parameter = specSelectors.getParameter(pathMethod, param.get("name"))
let parameter = specSelectors.getParameter(pathMethod, param.get("name"), param.get("in"))
let value = parameter ? parameter.get("value") : ""
if ( defaultValue !== undefined && value === undefined ) {
this.onChangeWrapper(defaultValue)
@@ -86,7 +86,7 @@ export default class ParameterRow extends Component {
let isFormDataSupported = "FormData" in win
let required = param.get("required")
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
let parameter = specSelectors.getParameter(pathMethod, param.get("name"))
let parameter = specSelectors.getParameter(pathMethod, param.get("name"), param.get("in"))
let value = parameter ? parameter.get("value") : ""
return (
+2 -2
View File
@@ -37,7 +37,7 @@ export default class Parameters extends Component {
onChangeKey,
} = this.props
changeParam( onChangeKey, param.get("name"), value, isXml)
changeParam( onChangeKey, param.get("name"), param.get("in"), value, isXml)
}
onChangeConsumesWrapper = ( val ) => {
@@ -94,7 +94,7 @@ export default class Parameters extends Component {
<ParameterRow fn={ fn }
getComponent={ getComponent }
param={ parameter }
key={ parameter.get( "name" ) }
key={ `${parameter.get( "in" )}.${parameter.get("name")}` }
onChange={ this.onChange }
onChangeConsumes={this.onChangeConsumesWrapper}
specSelectors={ specSelectors }
+2 -1
View File
@@ -23,6 +23,7 @@ export default class Primitive extends Component {
let format = schema.get("format")
let xml = schema.get("xml")
let enumArray = schema.get("enum")
let title = schema.get("title") || name
let description = schema.get("description")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
const Markdown = getComponent("Markdown")
@@ -30,7 +31,7 @@ export default class Primitive extends Component {
return <span className="model">
<span className="prop">
{ name && <span className={`${depth === 1 && "model-title"} prop-name`}>{ name }</span> }
{ name && <span className={`${depth === 1 && "model-title"} prop-name`}>{ title }</span> }
<span className="prop-type">{ type }</span>
{ format && <span className="prop-format">(${format})</span>}
{
+8
View File
@@ -107,6 +107,14 @@ export default class Response extends React.Component {
includeWriteOnly: true // writeOnly has no filtering effect in swagger 2.0
}) : null
}
if(examples) {
examples = examples.map(example => {
// Remove unwanted properties from examples
return example.set("$$ref", undefined)
})
}
let example = getExampleComponent( sampleResponse, examples, HighlightCode )
return (
+2 -1
View File
@@ -64,7 +64,8 @@ export default function authorize ( { auth, authActions, errActions, configs, au
}
}
let url = [schema.get("authorizationUrl"), query.join("&")].join("?")
let authorizationUrl = schema.get("authorizationUrl")
let url = [authorizationUrl, query.join("&")].join(authorizationUrl.indexOf("?") === -1 ? "?" : "&")
// pass action authorizeOauth2 and authentication data through window
// to authorize with oauth2
@@ -49,7 +49,7 @@ class Parameters extends Component {
onChangeKey,
} = this.props
changeParam( onChangeKey, param.get("name"), value, isXml)
changeParam( onChangeKey, param.get("name"), param.get("in"), value, isXml)
}
onChangeConsumesWrapper = ( val ) => {
+2 -3
View File
@@ -130,10 +130,10 @@ export const formatIntoYaml = () => ({specActions, specSelectors}) => {
}
}
export function changeParam( path, paramName, value, isXml ){
export function changeParam( path, paramName, paramIn, value, isXml ){
return {
type: UPDATE_PARAM,
payload:{ path, value, paramName, isXml }
payload:{ path, value, paramName, paramIn, isXml }
}
}
@@ -206,7 +206,6 @@ export const executeRequest = (req) =>
// if url is relative, parseUrl makes it absolute by inferring from `window.location`
req.contextUrl = parseUrl(specSelectors.url()).toString()
if(op && op.operationId) {
req.operationId = op.operationId
} else if(op && pathName && method) {
+3 -2
View File
@@ -40,9 +40,10 @@ export default {
},
[UPDATE_PARAM]: ( state, {payload} ) => {
let { path, paramName, value, isXml } = payload
let { path, paramName, paramIn, value, isXml } = payload
return state.updateIn( [ "resolved", "paths", ...path, "parameters" ], fromJS([]), parameters => {
const index = parameters.findIndex(p => p.get( "name" ) === paramName )
const index = parameters.findIndex(p => p.get( "name" ) === paramName && p.get("in") === paramIn )
if (!(value instanceof win.File)) {
value = fromJSOrdered( value )
}
+3 -3
View File
@@ -260,10 +260,10 @@ export const allowTryItOutFor = () => {
}
// Get the parameter value by parameter name
export function getParameter(state, pathMethod, name) {
export function getParameter(state, pathMethod, name, inType) {
let params = spec(state).getIn(["paths", ...pathMethod, "parameters"], fromJS([]))
return params.filter( (p) => {
return Map.isMap(p) && p.get("name") === name
return Map.isMap(p) && p.get("name") === name && p.get("in") === inType
}).first()
}
@@ -280,7 +280,7 @@ export function parameterValues(state, pathMethod, isXml) {
let params = spec(state).getIn(["paths", ...pathMethod, "parameters"], fromJS([]))
return params.reduce( (hash, p) => {
let value = isXml && p.get("in") === "body" ? p.get("value_xml") : p.get("value")
return hash.set(p.get("name"), value)
return hash.set(`${p.get("in")}.${p.get("name")}`, value)
}, fromJS({}))
}
+21 -1
View File
@@ -500,12 +500,25 @@ export const validateString = ( val ) => {
}
}
export const validateDateTime = (val) => {
if (isNaN(Date.parse(val))) {
return "Value must be a DateTime"
}
}
export const validateGuid = (val) => {
if (!/^[{(]?[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}[)}]?$/.test(val)) {
return "Value must be a Guid"
}
}
// validation of parameters before execute
export const validateParam = (param, isXml) => {
let errors = []
let value = isXml && param.get("in") === "body" ? param.get("value_xml") : param.get("value")
let required = param.get("required")
let type = param.get("type")
let format = param.get("format")
/*
If the parameter is required OR the parameter has a value (meaning optional, but filled in)
@@ -528,7 +541,14 @@ export const validateParam = (param, isXml) => {
}
if ( type === "string" ) {
let err = validateString(value)
let err
if (format === "date-time") {
err = validateDateTime(value)
} else if (format === "uuid") {
err = validateGuid(value)
} else {
err = validateString(value)
}
if (!err) return errors
errors.push(err)
} else if ( type === "boolean" ) {
+2 -1
View File
@@ -237,7 +237,8 @@ span
.prop-name
{
display: inline-block;
width: 100px;
margin-right: 1em;
width: 8em;
}
.prop-type
+49
View File
@@ -0,0 +1,49 @@
/* eslint-env mocha */
import React from "react"
import expect from "expect"
import { shallow } from "enzyme"
import { fromJS } from "immutable"
import PrimitiveModel from "components/primitive-model"
describe("<PrimitiveModel/>", function() {
describe("Model name", function() {
const dummyComponent = () => null
const components = {
Markdown: dummyComponent,
EnumModel: dummyComponent
}
const props = {
getComponent: c => components[c],
name: "Name from props",
depth: 1,
schema: fromJS({
type: "string",
title: "Custom model title"
})
}
it("renders the schema's title", function() {
// When
const wrapper = shallow(<PrimitiveModel {...props}/>)
const modelTitleEl = wrapper.find("span.model-title")
expect(modelTitleEl.length).toEqual(1)
// Then
expect( modelTitleEl.text() ).toEqual( "Custom model title" )
})
it("falls back to the passed-in `name` prop for the title", function() {
// When
props.schema = fromJS({
type: "string"
})
const wrapper = shallow(<PrimitiveModel {...props}/>)
const modelTitleEl = wrapper.find("span.model-title")
expect(modelTitleEl.length).toEqual(1)
// Then
expect( modelTitleEl.text() ).toEqual( "Name from props" )
})
})
} )
+39
View File
@@ -0,0 +1,39 @@
/* eslint-env mocha */
import expect, { createSpy } from "expect"
import { fromJS } from "immutable"
import win from "core/window"
import oauth2Authorize from "core/oauth2-authorize"
describe("oauth2", function () {
let mockSchema = {
flow: "accessCode",
authorizationUrl: "https://testAuthorizationUrl"
}
let authConfig = {
auth: { schema: { get: (key)=> mockSchema[key] } },
authActions: {},
errActions: {},
configs: { oauth2RedirectUrl: "" },
authConfigs: {}
}
describe("authorize redirect", function () {
it("should build authorize url", function() {
win.open = createSpy()
oauth2Authorize(authConfig)
expect(win.open.calls.length).toEqual(1)
expect(win.open.calls[0].arguments[0]).toMatch("https://testAuthorizationUrl?response_type=code&redirect_uri=&state=")
})
it("should append query paramters to authorizeUrl with query parameters", function() {
win.open = createSpy()
mockSchema.authorizationUrl = "https://testAuthorizationUrl?param=1"
oauth2Authorize(authConfig)
expect(win.open.calls.length).toEqual(1)
expect(win.open.calls[0].arguments[0]).toMatch("https://testAuthorizationUrl?param=1&response_type=code&redirect_uri=&state=")
})
})
})
+4 -4
View File
@@ -29,8 +29,8 @@ describe("spec plugin - selectors", function(){
"/one": {
get: {
parameters: [
{ name: "one", value: 1},
{ name: "two", value: "duos"}
{ name: "one", in: "query", value: 1},
{ name: "two", in: "query", value: "duos"}
]
}
}
@@ -43,8 +43,8 @@ describe("spec plugin - selectors", function(){
// Then
expect(paramValues.toJS()).toEqual({
one: 1,
two: "duos"
"query.one": 1,
"query.two": "duos"
})
})
+30 -3
View File
@@ -1,7 +1,7 @@
/* eslint-env mocha */
import expect from "expect"
import { fromJS, OrderedMap } from "immutable"
import { mapToList, validateNumber, validateInteger, validateParam, validateFile, fromJSOrdered, getAcceptControllingResponse, createDeepLinkPath, escapeDeepLinkPath } from "core/utils"
import { mapToList, validateDateTime, validateGuid, validateNumber, validateInteger, validateParam, validateFile, fromJSOrdered, getAcceptControllingResponse, createDeepLinkPath, escapeDeepLinkPath } from "core/utils"
import win from "core/window"
describe("utils", function() {
@@ -158,7 +158,7 @@ describe("utils", function() {
})
})
describe("validateFile", function() {
describe("validateFile", function() {
let errorMessage = "Value must be a file"
it("validates against objects which are instances of 'File'", function() {
@@ -171,6 +171,33 @@ describe("utils", function() {
})
})
describe("validateDateTime", function() {
let errorMessage = "Value must be a DateTime"
it("doesn't return for valid dates", function() {
expect(validateDateTime("Mon, 25 Dec 1995 13:30:00 +0430")).toBeFalsy()
})
it("returns a message for invalid input'", function() {
expect(validateDateTime(null)).toEqual(errorMessage)
expect(validateDateTime("string")).toEqual(errorMessage)
})
})
describe("validateGuid", function() {
let errorMessage = "Value must be a Guid"
it("doesn't return for valid guid", function() {
expect(validateGuid("8ce4811e-cec5-4a29-891a-15d1917153c1")).toBeFalsy()
expect(validateGuid("{8ce4811e-cec5-4a29-891a-15d1917153c1}")).toBeFalsy()
})
it("returns a message for invalid input'", function() {
expect(validateGuid(1)).toEqual(errorMessage)
expect(validateGuid("string")).toEqual(errorMessage)
})
})
describe("validateParam", function() {
let param = null
let result = null
@@ -583,7 +610,7 @@ describe("utils", function() {
})
})
describe.only("getAcceptControllingResponse", () => {
describe("getAcceptControllingResponse", () => {
it("should return the first 2xx response with a media type", () => {
const responses = fromJSOrdered({
"200": {