Completed
Push — master ( 3667f8...339eda )
by Alan
23s
created

cent-provider.spec.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 1
rs 10
nop 0
1
/* global jest, it, describe, expect */
2
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