Total Complexity | 6 |
Complexity/F | 1 |
Lines of Code | 31 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /* global jest, it, describe, expect */ |
||
3 | jest.unmock('../src/cent-provider') |
||
4 | import React from 'react' |
||
5 | import PropTypes from 'prop-types' |
||
6 | import CentProvider from '../src/cent-provider' |
||
7 | |||
8 | describe('CentProvider', () => { |
||
9 | const config = {url: 'http://localhost:8000/connect', insecure: true} |
||
10 | |||
11 | it('should throw Exception if the `url` ' + |
||
12 | 'is not provided in the configuration', () => { |
||
13 | expect(() => { CentProvider({}) }).toThrow() |
||
14 | }) |
||
15 | |||
16 | it('should provide `cent` context', () => { |
||
17 | const wrapper = new CentProvider({config}) |
||
18 | expect(wrapper.getChildContext().cent.constructor.name).toBe('Centrifuge') |
||
19 | expect(CentProvider.childContextTypes.cent).toBe(PropTypes.object.isRequired) |
||
20 | }) |
||
21 | |||
22 | it('should render children', () => { |
||
23 | const div = React.createFactory('div') |
||
24 | const children = React.createElement(div) |
||
25 | const wrapper = new CentProvider({config, children}) |
||
26 | const render = wrapper.render() |
||
27 | expect(render).toBe(children) |
||
28 | }) |
||
29 | |||
30 | it('should have children proptype required', () => { |
||
31 | expect(CentProvider.propTypes.children).toBe(PropTypes.element.isRequired) |
||
32 | }) |
||
33 | }) |
||
34 |