Skip to content
Snippets Groups Projects
Commit f72dc631 authored by Andrew Winget (Standard)'s avatar Andrew Winget (Standard)
Browse files

modify tests to begin testing lifecycle methods

parent 72870555
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ describe('actions', () => {
collectionIndex: 0,
manifestId: null,
rangeId: null,
xywh: [0, 0, 200, 200],
xywh: [0, 0, 400, 400],
rotation: null,
},
};
......
import React from 'react';
import { shallow } from 'enzyme';
import { mount } from 'enzyme';
import { actions, store } from '../../../src/store';
import Window from '../../../src/components/Window';
import fixture from '../../fixtures/2.json';
......@@ -11,11 +11,13 @@ describe('Window', () => {
store.dispatch(actions.receiveManifest('foo', fixture));
store.dispatch(actions.addWindow({ manifestId: 'foo' }));
[window] = store.getState().windows;
wrapper = shallow(<Window store={store} id={window.id} />).dive();
wrapper = mount(<Window store={store} id={window.id} />);
});
it('returns the width and height style attribute', () => {
expect(wrapper.instance().styleAttributes()).toEqual({ width: '400px', height: '400px' });
console.log("IT's HEEEEEEEEEEEEEEEEEERE!");
console.log(wrapper.debug());
expect(wrapper.ref('div').styleAttributes()).toEqual({ width: '400px', height: '400px' });
});
it('renders without an error', () => {
......
// Setup Jest to mock fetch
import { JSDOM } from 'jsdom'; // import jsdom for tests on code that is not fully-managed by react (openseadragon, for instance)
import fetch from 'jest-fetch-mock'; // eslint-disable-line import/no-extraneous-dependencies
import Enzyme from 'enzyme'; // eslint-disable-line import/no-extraneous-dependencies
import Adapter from 'enzyme-adapter-react-16'; // eslint-disable-line import/no-extraneous-dependencies
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');
const { window } = jsdom;
function copyProps(src, target) {
const props = Object.getOwnPropertyNames(src)
.filter(prop => typeof target[prop] === 'undefined')
.reduce((result, prop) => ({
...result,
[prop]: Object.getOwnPropertyDescriptor(src, prop),
}), {});
Object.defineProperties(target, props);
}
jest.setMock('node-fetch', fetch);
global.fetch = require('jest-fetch-mock'); // eslint-disable-line import/no-extraneous-dependencies
global.window = window;
global.document = window.document;
global.navigator = {
userAgent: 'node.js',
};
copyProps(window, global);
Enzyme.configure({ adapter: new Adapter() });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment