forked from opentok/opentok-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preloadScript.spec.js
33 lines (25 loc) · 1.1 KB
/
preloadScript.spec.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
import React from 'react';
import { mount } from 'enzyme';
import preloadScript from '../src/preloadScript';
describe('preloadScript', () => {
it('Should render loadingDelegate when OT is not available', () => {
const oldOT = global.OT;
global.OT = undefined;
const OTModule = preloadScript(() => <div className="opentok-module" />);
const loadingDelegate = <div className="loading-delegate" />;
const wrapper = mount(<OTModule loadingDelegate={loadingDelegate} />);
const divContainer = wrapper.render().find('div.loading-delegate');
expect(divContainer.length).toBe(1);
global.OT = oldOT;
});
it('Should render its inner component when OT is available', () => {
const oldOT = global.OT;
global.OT = {};
const OTModule = preloadScript(() => <div className="opentok-module" />);
const loadingDelegate = <div className="loading-delegate" />;
const wrapper = mount(<OTModule loadingDelegate={loadingDelegate} />);
const divContainer = wrapper.render().find('div.opentok-module');
expect(divContainer.length).toBe(1);
global.OT = oldOT;
});
});