* config(jest): updated setup * config(jest): update testMatch to include jsx files * config(jest): add transformIgnorePatterns * config(jest): update ignore files that do not work in jest yet * config: add test:unit-jest to test script * fix(jest): lint with eslint-plugin-jest * refactor(jest): move unit test directory * refactor(mocha): restore mocha tests that fail in jest * docs(jest): update helpful scripts with test:unit-jest
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import React from "react"
|
|
import { shallow } from "enzyme"
|
|
import { fromJS, Map } from "immutable"
|
|
import Models from "components/models"
|
|
import ModelCollpase from "components/model-collapse"
|
|
import ModelComponent from "components/model-wrapper"
|
|
|
|
describe("<Models/>", function(){
|
|
// Given
|
|
let components = {
|
|
Collapse: ModelCollpase,
|
|
ModelWrapper: ModelComponent
|
|
}
|
|
let props = {
|
|
getComponent: (c) => {
|
|
return components[c]
|
|
},
|
|
specSelectors: {
|
|
isOAS3: () => false,
|
|
specJson: () => Map(),
|
|
definitions: function() {
|
|
return fromJS({
|
|
def1: {},
|
|
def2: {}
|
|
})
|
|
},
|
|
specResolvedSubtree: () => {}
|
|
},
|
|
layoutSelectors: {
|
|
isShown: jest.fn()
|
|
},
|
|
layoutActions: {},
|
|
getConfigs: () => ({
|
|
docExpansion: "list",
|
|
defaultModelsExpandDepth: 0
|
|
})
|
|
}
|
|
|
|
|
|
it("passes defaultModelsExpandDepth to ModelWrapper", function(){
|
|
// When
|
|
let wrapper = shallow(<Models {...props}/>)
|
|
|
|
// Then should render tabs
|
|
expect(wrapper.find("ModelCollapse").length).toEqual(1)
|
|
expect(wrapper.find("ModelWrapper").length).toBeGreaterThan(0)
|
|
wrapper.find("ModelComponent").forEach((modelWrapper) => {
|
|
expect(modelWrapper.props().expandDepth).toBe(0)
|
|
})
|
|
})
|
|
|
|
})
|