application/__tests__/components/app-test.js
jest.unmock('./../../components/app');
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import Immutable from 'immutable';
import sinon from 'sinon';
import AltTestingUtils from 'alt-utils/lib/AltTestingUtils';
import App from './../../components/app';
import Spashy from './../../components/common/splashy';
import DropZone from './../../components/common/dropzone';
describe('AppComponent', () => {
let spy;
beforeEach(() => {
jasmine.clock().uninstall();
jasmine.clock().install();
});
afterEach(() => {
jasmine.clock().uninstall();
});
it('loads spash screen', () => {
const app = TestUtils.renderIntoDocument(
<App />
);
const node = ReactDOM.findDOMNode(app);
const splash = TestUtils.scryRenderedComponentsWithType(app, Spashy);
expect(app.state.shouldStart).toEqual(false);
expect(splash.length).toEqual(1);
});
it('loads app after 2 seconds', () => {
const app = TestUtils.renderIntoDocument(
<App />
);
const node = ReactDOM.findDOMNode(app);
const splash = TestUtils.scryRenderedComponentsWithType(app, Spashy);
expect(app.state.shouldStart).toEqual(false);
expect(splash.length).toEqual(1);
jasmine.clock().tick(2001);
});
it('loads dropzone on drag enter', () => {
const app = TestUtils.renderIntoDocument(
<App />
);
jasmine.clock().tick(2001);
let dz = TestUtils.scryRenderedComponentsWithType(app, DropZone);
expect(dz.length).toEqual(0);
const node = ReactDOM.findDOMNode(app);
TestUtils.Simulate.dragEnter(node, {});
dz = TestUtils.scryRenderedComponentsWithType(app, DropZone);
expect(dz.length).toEqual(1);
});
});