未验证 提交 f523ec40 编写于 作者: K kyle 提交者: GitHub

housekeeping: reorganize and rewire Mocha tests (#5600)

* move Mocha-run tests to `test/mocha`

* fix relative paths

* fix JSX test paths

* update stagnated JSX tests

* `test/setup.js` -> `test/mocha/setup.js`

* use regex+globstar for test matching

* remove `console.log`
上级 c3890c21
......@@ -30,7 +30,7 @@
"lint-fix": "eslint --cache --ext '.js,.jsx' src test --fix",
"test": "run-s just-test-in-node e2e-cypress lint-errors",
"test-in-node": "run-s lint-errors just-test-in-node",
"just-test-in-node": "mocha --require test/setup.js --recursive --compilers js:@babel/register --require source-map-support test/core test/components test/bugs test/docker test/swagger-ui-dist-package test/xss",
"just-test-in-node": "mocha --require test/mocha/setup.js --recursive --compilers js:@babel/register --require source-map-support 'test/mocha/**/*.{js,jsx}'",
"test-e2e-cypress": "cypress run",
"test-e2e-selenium": "sleep 3 && nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json",
"e2e-initial-render": "nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json --group initial-render",
......
......@@ -56,6 +56,9 @@ describe("bug #4557: default parameter values", function(){
isOAS3(){ return true },
isSwagger2() { return false }
},
oas3Selectors: {
activeExamplesMember: () => null
},
fn: {},
operation: {get: ()=>{}},
onChange: createSpy(),
......
......@@ -163,7 +163,7 @@ describe("<JsonSchemaForm/>", function(){
let props = {
getComponent: getComponentStub,
value: "",
value: `{\n "id": "abc123"\n}`,
onChange: (value) => {
updateQueue.push({ value })
},
......
......@@ -3,7 +3,7 @@ import React from "react"
import expect from "expect"
import { render } from "enzyme"
import Markdown from "components/providers/markdown"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.js"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.jsx"
describe("Markdown component", function() {
describe("Swagger 2.0", function() {
......
......@@ -29,7 +29,9 @@ describe("<ModelExample/>", function(){
getComponent: (c) => {
return components[c]
},
specSelectors: {},
specSelectors: {
isOAS3: () => false
},
schema: {},
example: "{\"example\": \"value\"}",
isExecute: false,
......
import React from "react"
import expect from "expect"
import { shallow } from "enzyme"
import { fromJS } from "immutable"
import { fromJS, List } from "immutable"
import Response from "components/response"
import ModelExample from "components/model-example"
import { inferSchema } from "corePlugins/samples/fn"
......@@ -28,7 +28,9 @@ describe("<Response />", function() {
},
contentType: "application/json",
className: "for-test",
specPath: List(),
response: fromJS({
schema: {
type: "object",
properties: {
// Note reverse order: c, b, a
......@@ -42,6 +44,7 @@ describe("<Response />", function() {
type: "string"
}
}
}
}),
code: "200"
}
......@@ -55,4 +58,4 @@ describe("<Response />", function() {
const modelExampleSchemaProperties = renderedModelExample.props().schema.toJS().properties
expect( Object.keys(modelExampleSchemaProperties) ).toEqual(["c", "b", "a"])
})
})
\ No newline at end of file
})
......@@ -4,7 +4,7 @@
import expect from "expect"
import Im, { fromJS } from "immutable"
import getParameterSchema from "../../../src/helpers/get-parameter-schema"
import getParameterSchema from "../../../../src/helpers/get-parameter-schema"
describe("getParameterSchema", () => {
it("should return an empty Map when given no parameters", () => {
......
const expect = require("expect")
const oauthBlockBuilder = require("../../docker/configurator/oauth")
const oauthBlockBuilder = require("../../../docker/configurator/oauth")
const dedent = require("dedent")
describe("docker: env translator - oauth block", function() {
......@@ -55,4 +55,4 @@ describe("docker: env translator - oauth block", function() {
additionalQueryStringParams: { "a": 1234, "b": "stuff" },
})`))
})
})
\ No newline at end of file
})
const expect = require("expect")
const translator = require("../../docker/configurator/translator")
const translator = require("../../../docker/configurator/translator")
const dedent = require("dedent")
describe("docker: env translator", function() {
......@@ -336,4 +336,4 @@ describe("docker: env translator", function() {
).trim())
})
})
})
\ No newline at end of file
})
/* eslint-env mocha */
import expect from "expect"
import path from "path"
import getAbsoluteFSPath from "../../swagger-ui-dist-package/absolute-path"
import getAbsoluteFSPath from "../../../swagger-ui-dist-package/absolute-path"
describe("swagger-ui-dist", function(){
describe("getAbsoluteFSPath", function(){
it("returns absolute path", function(){
const expectedPath = path.resolve(__dirname, "../../swagger-ui-dist-package")
const expectedPath = path.resolve(__dirname, "../../../swagger-ui-dist-package")
expect(getAbsoluteFSPath()).toEqual(expectedPath)
})
})
......
......@@ -3,7 +3,7 @@ import React from "react"
import expect from "expect"
import { render } from "enzyme"
import Markdown from "components/providers/markdown"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.js"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.jsx"
describe("Markdown Link Anchor Safety", function () {
describe("Swagger 2.0", function () {
......@@ -63,4 +63,4 @@ function withMarkdownWrapper(str, { isOAS3 = false } = {}) {
}
return `<div class="markdown"><p>${str}</p>\n</div>`
}
\ No newline at end of file
}
......@@ -3,7 +3,7 @@ import React from "react"
import expect from "expect"
import { render } from "enzyme"
import Markdown from "components/providers/markdown"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.js"
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.jsx"
describe("Markdown Script Sanitization", function() {
describe("Swagger 2.0", function() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册