Skip to content

Commit

Permalink
housekeeping: reorganize and rewire Mocha tests (#5600)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
shockey authored Sep 11, 2019
1 parent c3890c2 commit f523ec4
Show file tree
Hide file tree
Showing 56 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe("<JsonSchemaForm/>", function(){

let props = {
getComponent: getComponentStub,
value: "",
value: `{\n "id": "abc123"\n}`,
onChange: (value) => {
updateQueue.push({ value })
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe("<ModelExample/>", function(){
getComponent: (c) => {
return components[c]
},
specSelectors: {},
specSelectors: {
isOAS3: () => false
},
schema: {},
example: "{\"example\": \"value\"}",
isExecute: false,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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"
Expand All @@ -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
Expand All @@ -42,6 +44,7 @@ describe("<Response />", function() {
type: "string"
}
}
}
}),
code: "200"
}
Expand All @@ -55,4 +58,4 @@ describe("<Response />", function() {
const modelExampleSchemaProperties = renderedModelExample.props().schema.toJS().properties
expect( Object.keys(modelExampleSchemaProperties) ).toEqual(["c", "b", "a"])
})
})
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/docker/oauth.js → test/mocha/docker/oauth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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() {
Expand Down Expand Up @@ -55,4 +55,4 @@ describe("docker: env translator - oauth block", function() {
additionalQueryStringParams: { "a": 1234, "b": "stuff" },
})`))
})
})
})
4 changes: 2 additions & 2 deletions test/docker/translator.js → test/mocha/docker/translator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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() {
Expand Down Expand Up @@ -336,4 +336,4 @@ describe("docker: env translator", function() {
).trim())
})
})
})
})
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* 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)
})
})
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -63,4 +63,4 @@ function withMarkdownWrapper(str, { isOAS3 = false } = {}) {
}

return `<div class="markdown"><p>${str}</p>\n</div>`
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit f523ec4

Please sign in to comment.