Browse Source

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`
bubble
kyle 5 years ago
committed by GitHub
parent
commit
f523ec40f0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 24 additions and 16 deletions
  1. +1
    -1
      package.json
  2. +0
    -0
      test/mocha/bugs/3199-sanitization-escaping.jsx
  3. +0
    -0
      test/mocha/bugs/3279-empty-markdown-source.jsx
  4. +3
    -0
      test/mocha/bugs/4557-default-parameter-values.jsx
  5. +0
    -0
      test/mocha/components/filter.jsx
  6. +0
    -0
      test/mocha/components/info-wrapper.jsx
  7. +1
    -1
      test/mocha/components/json-schema-form.jsx
  8. +0
    -0
      test/mocha/components/live-response.jsx
  9. +1
    -1
      test/mocha/components/markdown.jsx
  10. +3
    -1
      test/mocha/components/model-example.jsx
  11. +0
    -0
      test/mocha/components/models.jsx
  12. +0
    -0
      test/mocha/components/object-model.jsx
  13. +0
    -0
      test/mocha/components/online-validator-badge.jsx
  14. +0
    -0
      test/mocha/components/operation.jsx
  15. +0
    -0
      test/mocha/components/operations.jsx
  16. +0
    -0
      test/mocha/components/primitive-model.jsx
  17. +0
    -0
      test/mocha/components/response-body.jsx
  18. +5
    -2
      test/mocha/components/response.jsx
  19. +0
    -0
      test/mocha/components/schemes-wrapper.jsx
  20. +0
    -0
      test/mocha/components/schemes.jsx
  21. +0
    -0
      test/mocha/components/version-pragma-filter.jsx
  22. +0
    -0
      test/mocha/core/curlify.js
  23. +1
    -1
      test/mocha/core/helpers/get-parameter-schema.js
  24. +0
    -0
      test/mocha/core/oauth2-authorize.js
  25. +0
    -0
      test/mocha/core/plugins/auth/actions.js
  26. +0
    -0
      test/mocha/core/plugins/auth/preauthorize.js
  27. +0
    -0
      test/mocha/core/plugins/auth/selectors.js
  28. +0
    -0
      test/mocha/core/plugins/auth/wrap-spec-actions.js
  29. +0
    -0
      test/mocha/core/plugins/configs/actions.js
  30. +0
    -0
      test/mocha/core/plugins/err/transformers/not-of-type.js
  31. +0
    -0
      test/mocha/core/plugins/err/transformers/parameter-oneof.js
  32. +0
    -0
      test/mocha/core/plugins/filter/opsFilter.js
  33. +0
    -0
      test/mocha/core/plugins/oas3/helpers.js
  34. +0
    -0
      test/mocha/core/plugins/oas3/servers-wrapper.jsx
  35. +0
    -0
      test/mocha/core/plugins/oas3/state-integration.js
  36. +0
    -0
      test/mocha/core/plugins/oas3/wrap-auth-selectors.js
  37. +0
    -0
      test/mocha/core/plugins/oas3/wrap-spec-selectors.js
  38. +0
    -0
      test/mocha/core/plugins/samples/fn.js
  39. +0
    -0
      test/mocha/core/plugins/spec/actions.js
  40. +0
    -0
      test/mocha/core/plugins/spec/assets/petstore.json
  41. +0
    -0
      test/mocha/core/plugins/spec/reducer.js
  42. +0
    -0
      test/mocha/core/plugins/spec/selectors.js
  43. +0
    -0
      test/mocha/core/plugins/swagger-js/withCredentials.js
  44. +0
    -0
      test/mocha/core/system/system.jsx
  45. +0
    -0
      test/mocha/core/system/wrapComponent.jsx
  46. +0
    -0
      test/mocha/core/utils.js
  47. +2
    -2
      test/mocha/docker/oauth.js
  48. +2
    -2
      test/mocha/docker/translator.js
  49. +0
    -0
      test/mocha/setup.js
  50. +2
    -2
      test/mocha/swagger-ui-dist-package/absolute-path.js
  51. +0
    -0
      test/mocha/xss/anchor-target-rel/info.jsx
  52. +0
    -0
      test/mocha/xss/anchor-target-rel/link.jsx
  53. +2
    -2
      test/mocha/xss/anchor-target-rel/markdown.jsx
  54. +0
    -0
      test/mocha/xss/anchor-target-rel/online-validator-badge.jsx
  55. +0
    -0
      test/mocha/xss/info-sanitization.jsx
  56. +1
    -1
      test/mocha/xss/markdown-script-sanitization.jsx

+ 1
- 1
package.json View File

@@ -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",


test/bugs/3199-sanitization-escaping.jsx → test/mocha/bugs/3199-sanitization-escaping.jsx View File


test/bugs/3279-empty-markdown-source.jsx → test/mocha/bugs/3279-empty-markdown-source.jsx View File


test/bugs/4557-default-parameter-values.jsx → test/mocha/bugs/4557-default-parameter-values.jsx View File

@@ -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(),

test/components/filter.jsx → test/mocha/components/filter.jsx View File


test/components/info-wrapper.jsx → test/mocha/components/info-wrapper.jsx View File


test/components/json-schema-form.jsx → test/mocha/components/json-schema-form.jsx View File

@@ -163,7 +163,7 @@ describe("<JsonSchemaForm/>", function(){

let props = {
getComponent: getComponentStub,
value: "",
value: `{\n "id": "abc123"\n}`,
onChange: (value) => {
updateQueue.push({ value })
},

test/components/live-response.jsx → test/mocha/components/live-response.jsx View File


test/components/markdown.jsx → test/mocha/components/markdown.jsx View 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 component", function() {
describe("Swagger 2.0", function() {

test/components/model-example.jsx → test/mocha/components/model-example.jsx View File

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

test/components/models.jsx → test/mocha/components/models.jsx View File


test/components/object-model.jsx → test/mocha/components/object-model.jsx View File


test/components/online-validator-badge.jsx → test/mocha/components/online-validator-badge.jsx View File


test/components/operation.jsx → test/mocha/components/operation.jsx View File


test/components/operations.jsx → test/mocha/components/operations.jsx View File


test/components/primitive-model.jsx → test/mocha/components/primitive-model.jsx View File


test/components/response-body.jsx → test/mocha/components/response-body.jsx View File


test/components/response.jsx → test/mocha/components/response.jsx View File

@@ -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"
@@ -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"])
})
})
})

test/components/schemes-wrapper.jsx → test/mocha/components/schemes-wrapper.jsx View File


test/components/schemes.jsx → test/mocha/components/schemes.jsx View File


test/components/version-pragma-filter.jsx → test/mocha/components/version-pragma-filter.jsx View File


test/core/curlify.js → test/mocha/core/curlify.js View File


test/core/helpers/get-parameter-schema.js → test/mocha/core/helpers/get-parameter-schema.js View 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", () => {

test/core/oauth2-authorize.js → test/mocha/core/oauth2-authorize.js View File


test/core/plugins/auth/actions.js → test/mocha/core/plugins/auth/actions.js View File


test/core/plugins/auth/preauthorize.js → test/mocha/core/plugins/auth/preauthorize.js View File


test/core/plugins/auth/selectors.js → test/mocha/core/plugins/auth/selectors.js View File


test/core/plugins/auth/wrap-spec-actions.js → test/mocha/core/plugins/auth/wrap-spec-actions.js View File


test/core/plugins/configs/actions.js → test/mocha/core/plugins/configs/actions.js View File


test/core/plugins/err/transformers/not-of-type.js → test/mocha/core/plugins/err/transformers/not-of-type.js View File


test/core/plugins/err/transformers/parameter-oneof.js → test/mocha/core/plugins/err/transformers/parameter-oneof.js View File


test/core/plugins/filter/opsFilter.js → test/mocha/core/plugins/filter/opsFilter.js View File


test/core/plugins/oas3/helpers.js → test/mocha/core/plugins/oas3/helpers.js View File


test/core/plugins/oas3/servers-wrapper.jsx → test/mocha/core/plugins/oas3/servers-wrapper.jsx View File


test/core/plugins/oas3/state-integration.js → test/mocha/core/plugins/oas3/state-integration.js View File


test/core/plugins/oas3/wrap-auth-selectors.js → test/mocha/core/plugins/oas3/wrap-auth-selectors.js View File


test/core/plugins/oas3/wrap-spec-selectors.js → test/mocha/core/plugins/oas3/wrap-spec-selectors.js View File


test/core/plugins/samples/fn.js → test/mocha/core/plugins/samples/fn.js View File


test/core/plugins/spec/actions.js → test/mocha/core/plugins/spec/actions.js View File


test/core/plugins/spec/assets/petstore.json → test/mocha/core/plugins/spec/assets/petstore.json View File


test/core/plugins/spec/reducer.js → test/mocha/core/plugins/spec/reducer.js View File


test/core/plugins/spec/selectors.js → test/mocha/core/plugins/spec/selectors.js View File


test/core/plugins/swagger-js/withCredentials.js → test/mocha/core/plugins/swagger-js/withCredentials.js View File


test/core/system/system.jsx → test/mocha/core/system/system.jsx View File


test/core/system/wrapComponent.jsx → test/mocha/core/system/wrapComponent.jsx View File


test/core/utils.js → test/mocha/core/utils.js View File


test/docker/oauth.js → test/mocha/docker/oauth.js View File

@@ -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() {
@@ -55,4 +55,4 @@ describe("docker: env translator - oauth block", function() {
additionalQueryStringParams: { "a": 1234, "b": "stuff" },
})`))
})
})
})

test/docker/translator.js → test/mocha/docker/translator.js View File

@@ -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() {
@@ -336,4 +336,4 @@ describe("docker: env translator", function() {
).trim())
})
})
})
})

test/setup.js → test/mocha/setup.js View File


test/swagger-ui-dist-package/absolute-path.js → test/mocha/swagger-ui-dist-package/absolute-path.js View File

@@ -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)
})
})

test/xss/anchor-target-rel/info.jsx → test/mocha/xss/anchor-target-rel/info.jsx View File


test/xss/anchor-target-rel/link.jsx → test/mocha/xss/anchor-target-rel/link.jsx View File


test/xss/anchor-target-rel/markdown.jsx → test/mocha/xss/anchor-target-rel/markdown.jsx View 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 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>`
}
}

test/xss/anchor-target-rel/online-validator-badge.jsx → test/mocha/xss/anchor-target-rel/online-validator-badge.jsx View File


test/xss/info-sanitization.jsx → test/mocha/xss/info-sanitization.jsx View File


test/xss/markdown-script-sanitization.jsx → test/mocha/xss/markdown-script-sanitization.jsx View 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() {

Loading…
Cancel
Save