react-openfin-mat-impl
Version:
Materialize UI implementation of react-openfin
48 lines • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const enzyme_to_json_1 = require("enzyme-to-json");
const styles_1 = require("@material-ui/core/styles");
const styles_2 = require("@material-ui/styles");
const test_utils_1 = require("@material-ui/core/test-utils");
const Button_1 = require("@material-ui/core/Button");
const ConfigAboutField_1 = require("./ConfigAboutField");
const theme = styles_1.createMuiTheme({});
describe('ConfigAboutField comp', () => {
let shallow;
let mount;
beforeEach(() => {
shallow = test_utils_1.createShallow();
mount = test_utils_1.createMount();
});
afterEach(() => {
mount.cleanUp();
});
it('renderred correctly', () => {
const wrapper = shallow(React.createElement(styles_2.ThemeProvider, { theme: theme },
React.createElement(ConfigAboutField_1.default, { appLogo: '', companyLogo: '', supporterEmail: '' })));
// const comp = wrapper.dive();
expect(enzyme_to_json_1.default(wrapper)).toMatchSnapshot();
});
it('function correctly', () => {
const oldLocation = window.location;
delete window.location;
window.location = {};
location.reload = jest.fn();
window.location.assign = jest.fn((l) => {
expect(l).toMatchSnapshot();
});
const wrapper = mount(React.createElement(styles_2.ThemeProvider, { theme: theme },
React.createElement(ConfigAboutField_1.default, { appLogo: '', companyLogo: '', supporterEmail: '' })));
expect(wrapper.find(Button_1.default)).toHaveLength(2);
wrapper.find(Button_1.default).forEach((button) => {
const props = button.props();
if (typeof props.onClick === 'function') {
props.onClick();
}
});
expect(location.reload).toHaveBeenCalled();
window.location = oldLocation;
});
});
//# sourceMappingURL=ConfigAboutField.spec.js.map