11import React , { Component } from 'react'
2- import expect from 'expect'
32import PropTypes from 'prop-types'
43import TestUtils from 'react-dom/test-utils'
54import { ThemeProvider } from '../../src/index'
65
7- before ( function ( ) {
8- /* eslint-disable no- console */
9- console . error = function ( ) { }
6+ beforeEach ( ( ) => {
7+ jest . spyOn ( console , 'error' )
8+ global . console . error . mockImplementation ( ( ) => { } )
109} )
1110
12- after ( function ( ) {
13- delete console . error
11+ afterEach ( ( ) => {
12+ global . console . error . mockRestore ( )
1413} )
1514
1615describe ( 'ThemeProvider' , ( ) => {
@@ -24,7 +23,7 @@ describe('ThemeProvider', () => {
2423 themr : PropTypes . object . isRequired
2524 }
2625
27- it ( 'enforces a single child' , ( ) => {
26+ test ( 'enforces a single child' , ( ) => {
2827 const theme = { }
2928
3029 // Ignore propTypes warnings
@@ -38,7 +37,7 @@ describe('ThemeProvider', () => {
3837 < div />
3938 </ ThemeProvider >
4039 )
41- ) . toNotThrow ( )
40+ ) . not . toThrow ( )
4241
4342 expect ( ( ) =>
4443 TestUtils . renderIntoDocument (
@@ -57,7 +56,7 @@ describe('ThemeProvider', () => {
5756 }
5857 } )
5958
60- it ( 'should add the theme to the child context' , ( ) => {
59+ test ( 'should add the theme to the child context' , ( ) => {
6160 const theme = { }
6261
6362 TestUtils . renderIntoDocument (
@@ -66,14 +65,13 @@ describe('ThemeProvider', () => {
6665 </ ThemeProvider >
6766 )
6867
69- const spy = expect . spyOn ( console , 'error' )
68+ const spy = jest . spyOn ( console , 'error' )
7069 const tree = TestUtils . renderIntoDocument (
7170 < ThemeProvider theme = { theme } >
7271 < Child />
7372 </ ThemeProvider >
7473 )
75- spy . destroy ( )
76- expect ( spy . calls . length ) . toBe ( 0 )
74+ expect ( spy . mock . calls . length ) . toBe ( 0 )
7775
7876 const child = TestUtils . findRenderedComponentWithType ( tree , Child )
7977 expect ( child . context . themr . theme ) . toBe ( theme )
0 commit comments