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`
This commit is contained in:
kyle
2019-09-10 21:26:21 -07:00
committed by GitHub
parent c3890c210c
commit f523ec40f0
56 changed files with 24 additions and 16 deletions

View File

@@ -30,7 +30,7 @@
"lint-fix": "eslint --cache --ext '.js,.jsx' src test --fix", "lint-fix": "eslint --cache --ext '.js,.jsx' src test --fix",
"test": "run-s just-test-in-node e2e-cypress lint-errors", "test": "run-s just-test-in-node e2e-cypress lint-errors",
"test-in-node": "run-s lint-errors just-test-in-node", "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-cypress": "cypress run",
"test-e2e-selenium": "sleep 3 && nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json", "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", "e2e-initial-render": "nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json --group initial-render",

View File

@@ -56,6 +56,9 @@ describe("bug #4557: default parameter values", function(){
isOAS3(){ return true }, isOAS3(){ return true },
isSwagger2() { return false } isSwagger2() { return false }
}, },
oas3Selectors: {
activeExamplesMember: () => null
},
fn: {}, fn: {},
operation: {get: ()=>{}}, operation: {get: ()=>{}},
onChange: createSpy(), onChange: createSpy(),

View File

@@ -163,7 +163,7 @@ describe("<JsonSchemaForm/>", function(){
let props = { let props = {
getComponent: getComponentStub, getComponent: getComponentStub,
value: "", value: `{\n "id": "abc123"\n}`,
onChange: (value) => { onChange: (value) => {
updateQueue.push({ value }) updateQueue.push({ value })
}, },

View File

@@ -3,7 +3,7 @@ import React from "react"
import expect from "expect" import expect from "expect"
import { render } from "enzyme" import { render } from "enzyme"
import Markdown from "components/providers/markdown" 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("Markdown component", function() {
describe("Swagger 2.0", function() { describe("Swagger 2.0", function() {

View File

@@ -29,7 +29,9 @@ describe("<ModelExample/>", function(){
getComponent: (c) => { getComponent: (c) => {
return components[c] return components[c]
}, },
specSelectors: {}, specSelectors: {
isOAS3: () => false
},
schema: {}, schema: {},
example: "{\"example\": \"value\"}", example: "{\"example\": \"value\"}",
isExecute: false, isExecute: false,

View File

@@ -1,7 +1,7 @@
import React from "react" import React from "react"
import expect from "expect" import expect from "expect"
import { shallow } from "enzyme" import { shallow } from "enzyme"
import { fromJS } from "immutable" import { fromJS, List } from "immutable"
import Response from "components/response" import Response from "components/response"
import ModelExample from "components/model-example" import ModelExample from "components/model-example"
import { inferSchema } from "corePlugins/samples/fn" import { inferSchema } from "corePlugins/samples/fn"
@@ -28,7 +28,9 @@ describe("<Response />", function() {
}, },
contentType: "application/json", contentType: "application/json",
className: "for-test", className: "for-test",
specPath: List(),
response: fromJS({ response: fromJS({
schema: {
type: "object", type: "object",
properties: { properties: {
// Note reverse order: c, b, a // Note reverse order: c, b, a
@@ -42,6 +44,7 @@ describe("<Response />", function() {
type: "string" type: "string"
} }
} }
}
}), }),
code: "200" code: "200"
} }

View File

@@ -4,7 +4,7 @@
import expect from "expect" import expect from "expect"
import Im, { fromJS } from "immutable" import Im, { fromJS } from "immutable"
import getParameterSchema from "../../../src/helpers/get-parameter-schema" import getParameterSchema from "../../../../src/helpers/get-parameter-schema"
describe("getParameterSchema", () => { describe("getParameterSchema", () => {
it("should return an empty Map when given no parameters", () => { it("should return an empty Map when given no parameters", () => {

View File

@@ -1,5 +1,5 @@
const expect = require("expect") const expect = require("expect")
const oauthBlockBuilder = require("../../docker/configurator/oauth") const oauthBlockBuilder = require("../../../docker/configurator/oauth")
const dedent = require("dedent") const dedent = require("dedent")
describe("docker: env translator - oauth block", function() { describe("docker: env translator - oauth block", function() {

View File

@@ -1,5 +1,5 @@
const expect = require("expect") const expect = require("expect")
const translator = require("../../docker/configurator/translator") const translator = require("../../../docker/configurator/translator")
const dedent = require("dedent") const dedent = require("dedent")
describe("docker: env translator", function() { describe("docker: env translator", function() {

View File

@@ -1,12 +1,12 @@
/* eslint-env mocha */ /* eslint-env mocha */
import expect from "expect" import expect from "expect"
import path from "path" 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("swagger-ui-dist", function(){
describe("getAbsoluteFSPath", function(){ describe("getAbsoluteFSPath", function(){
it("returns absolute path", 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) expect(getAbsoluteFSPath()).toEqual(expectedPath)
}) })
}) })

View File

@@ -3,7 +3,7 @@ import React from "react"
import expect from "expect" import expect from "expect"
import { render } from "enzyme" import { render } from "enzyme"
import Markdown from "components/providers/markdown" 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("Markdown Link Anchor Safety", function () {
describe("Swagger 2.0", function () { describe("Swagger 2.0", function () {

View File

@@ -3,7 +3,7 @@ import React from "react"
import expect from "expect" import expect from "expect"
import { render } from "enzyme" import { render } from "enzyme"
import Markdown from "components/providers/markdown" 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("Markdown Script Sanitization", function() {
describe("Swagger 2.0", function() { describe("Swagger 2.0", function() {