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:
67
test/mocha/components/info-wrapper.jsx
Normal file
67
test/mocha/components/info-wrapper.jsx
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
/* eslint-env mocha */
|
||||
import React from "react"
|
||||
import expect from "expect"
|
||||
import { mount } from "enzyme"
|
||||
import { fromJS } from "immutable"
|
||||
import InfoContainer from "containers/info"
|
||||
|
||||
describe("<InfoContainer/>", function () {
|
||||
|
||||
const components = {
|
||||
info: () => <span className="mocked-info"/>
|
||||
}
|
||||
const mockedProps = {
|
||||
specSelectors: {
|
||||
info () {},
|
||||
url () {},
|
||||
basePath () {},
|
||||
host () {},
|
||||
externalDocs () {}
|
||||
},
|
||||
getComponent: c => components[c]
|
||||
}
|
||||
|
||||
it("renders Info inside InfoContainer if info is provided", function () {
|
||||
|
||||
// Given
|
||||
let props = {...mockedProps}
|
||||
props.specSelectors = {...mockedProps.specSelectors}
|
||||
props.specSelectors.info = function () {return fromJS(["info1", "info2"])}
|
||||
|
||||
// When
|
||||
let wrapper = mount(<InfoContainer {...props}/>)
|
||||
|
||||
// Then
|
||||
const renderedInfo = wrapper.find("span.mocked-info")
|
||||
expect(renderedInfo.length).toEqual(1)
|
||||
})
|
||||
|
||||
it("does not render Info inside InfoContainer if no info is provided", function () {
|
||||
|
||||
// Given
|
||||
let props = {...mockedProps}
|
||||
props.specSelectors = {...mockedProps.specSelectors}
|
||||
props.specSelectors.info = function () {return fromJS([])}
|
||||
|
||||
// When
|
||||
let wrapper = mount(<InfoContainer {...props}/>)
|
||||
|
||||
// Then
|
||||
const renderedInfo = wrapper.find("span.mocked-info")
|
||||
expect(renderedInfo.length).toEqual(0)
|
||||
})
|
||||
|
||||
it("does not render Info inside InfoContainer if info is undefined", function () {
|
||||
|
||||
// Given
|
||||
let props = {...mockedProps}
|
||||
|
||||
// When
|
||||
let wrapper = mount(<InfoContainer {...props}/>)
|
||||
|
||||
// Then
|
||||
const renderedInfo = wrapper.find("span.mocked-info")
|
||||
expect(renderedInfo.length).toEqual(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user