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

test/cent-provider.spec.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 31
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 6
c 1
b 0
f 0
nc 1
mnd 0
bc 6
fnc 6
dl 0
loc 31
rs 10
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B cent-provider.spec.js ➔ ??? 0 26 1
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