forked from airbnb/hypernova-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderReact-test.js
41 lines (33 loc) · 983 Bytes
/
renderReact-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import ExampleReactComponent from './components/ExampleReactComponent';
import jsdom from 'jsdom';
import { assert } from 'chai';
import { renderReact } from '..';
describe('renderReact', () => {
let result;
beforeEach(() => {
result = renderReact('ExampleReactComponent', ExampleReactComponent)({ name: 'Desmond' });
});
it('exists', () => {
assert.isFunction(renderReact);
assert.equal(renderReact.length, 2);
});
it('has correct markup on server', () => {
assert.isString(result);
assert.match(result, /Hello Desmond/);
});
it('calls hypernova.client', (done) => {
jsdom.env(result, (err, window) => {
if (err) {
done(err);
return;
}
global.window = window;
global.document = window.document;
// Calling it again for the client.
renderReact('ExampleReactComponent', ExampleReactComponent);
delete global.window;
delete global.document;
done();
});
});
});