Mailspring/spec/components/injected-component-set-spec.jsx

45 lines
1.3 KiB
React
Raw Normal View History

import {React, ComponentRegistry, NylasTestUtils} from 'nylas-exports';
import {InjectedComponentSet} from 'nylas-component-kit';
const {renderIntoDocument} = NylasTestUtils;
2016-05-06 13:30:34 +08:00
const reactStub = (displayName) => {
2016-05-07 05:10:28 +08:00
return <div className={displayName}></div>;
};
describe('InjectedComponentSet', function injectedComponentSet() {
2016-05-06 13:30:34 +08:00
describe('render', () => {
beforeEach(() => {
const components = [reactStub('comp1'), reactStub('comp2')];
spyOn(ComponentRegistry, 'findComponentsMatching').andReturn(components);
});
2016-05-06 13:30:34 +08:00
it('calls `onComponentsDidRender` when all child comps have actually been rendered to the dom', () => {
let rendered;
2016-05-06 13:30:34 +08:00
const onComponentsDidRender = () => {
rendered = true;
};
2016-05-06 13:30:34 +08:00
runs(() => {
renderIntoDocument(
<InjectedComponentSet
matching={{}}
2016-05-07 05:10:28 +08:00
onComponentsDidRender={onComponentsDidRender}
/>
);
});
waitsFor(
2016-05-06 13:30:34 +08:00
() => { return rendered; },
'`onComponentsDidMount` should be called',
100
);
2016-05-06 13:30:34 +08:00
runs(() => {
expect(rendered).toBe(true);
expect(document.querySelectorAll('.comp1').length).toEqual(1);
expect(document.querySelectorAll('.comp2').length).toEqual(1);
});
});
});
});