Skip to content

Commit 9fd98da

Browse files
committed
Clean up warnings in test suite
1 parent 1ce8962 commit 9fd98da

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

packages/editor/test/ColorPicker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import renderer from 'react-test-renderer'
33
import { render, fireEvent, cleanup } from '@testing-library/react'
44
import { Provider } from 'reakit/Provider'
5+
import mockConsole from 'jest-mock-console'
56
import { ColorPicker } from '../src'
67

78
const { act } = renderer
@@ -20,11 +21,16 @@ if (global.document) {
2021
}
2122

2223
test('renders with styles', () => {
24+
// ignore react-color dependency-related warning
25+
const restore = mockConsole()
2326
const json = renderer.create(<ColorPicker color="#f00" />).toJSON()
2427
expect(json).toMatchSnapshot()
28+
restore()
2529
})
2630

2731
test('snapshot renders as a popover', () => {
32+
// ignore react-color dependency-related warning
33+
const restore = mockConsole()
2834
const json = renderer
2935
.create(
3036
<Provider>
@@ -35,6 +41,7 @@ test('snapshot renders as a popover', () => {
3541
)
3642
.toJSON()
3743
expect(json).toMatchSnapshot()
44+
restore()
3845
})
3946

4047
/*

packages/tachyons/test/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'babel-polyfill'
22

33
import tachyonsGenerator from 'tachyons-generator'
4+
import mockConsole from 'jest-mock-console'
45
import toTachyons from '../src'
56

67
const theme = {
@@ -34,7 +35,10 @@ it('transforms a theme config to a Tachyons config', () => {
3435
})
3536

3637
it('generates the proper config for the Tachyons generator', async () => {
38+
// ignore warnings
39+
const restore = mockConsole()
3740
const { css: result } = await tachyonsGenerator(toTachyons(theme)).generate()
3841

3942
expect(result).toMatchSnapshot()
43+
restore()
4044
})

packages/theme-ui/test/color-modes.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ test('renders with initial color mode name', () => {
6161
<ThemeProvider
6262
theme={{
6363
initialColorModeName: 'light',
64+
colors: {
65+
modes: {
66+
dark: {},
67+
}
68+
}
6469
}}>
6570
<Mode />
6671
</ThemeProvider>
@@ -204,6 +209,11 @@ test('inherits color mode state from parent context', () => {
204209
<ThemeProvider
205210
theme={{
206211
initialColorModeName: 'outer',
212+
colors: {
213+
modes: {
214+
dark: {},
215+
}
216+
}
207217
}}>
208218
<ThemeProvider
209219
theme={{
@@ -337,6 +347,7 @@ test('ColorMode component renders with colors', () => {
337347
})
338348

339349
test('useColorMode throws when there is no theme context', () => {
350+
const restore = mockConsole()
340351
expect(() => {
341352
const Consumer = props => {
342353
const [colorMode] = useColorMode('beep')
@@ -345,6 +356,8 @@ test('useColorMode throws when there is no theme context', () => {
345356
}
346357
render(<Consumer />)
347358
}).toThrow()
359+
expect(console.error).toHaveBeenCalled()
360+
restore()
348361
})
349362

350363
test('useThemeUI returns current color mode colors', () => {
@@ -378,7 +391,6 @@ test('useThemeUI returns current color mode colors', () => {
378391

379392
test('warns when initialColorModeName matches a key in theme.colors.modes', () => {
380393
const restore = mockConsole()
381-
// jest.spyOn(global.console, 'warn')
382394
const root = render(
383395
<ThemeProvider
384396
theme={{

packages/theme-ui/test/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { mdx } from '@mdx-js/react'
33
import { useContext } from 'react'
44
import renderer from 'react-test-renderer'
55
import { matchers } from 'jest-emotion'
6+
import mockConsole from 'jest-mock-console'
67
import { ThemeProvider, Context, Styled, jsx, useColorMode } from '../src/index'
78

89
expect.extend(matchers)
@@ -122,7 +123,7 @@ test('custom pragma adds styles', () => {
122123
})
123124

124125
test('warns when multiple versions of emotion are installed', () => {
125-
jest.spyOn(global.console, 'warn')
126+
const restore = mockConsole()
126127
const json = renderJSON(
127128
<Context.Provider
128129
value={{
@@ -132,6 +133,7 @@ test('warns when multiple versions of emotion are installed', () => {
132133
</Context.Provider>
133134
)
134135
expect(console.warn).toBeCalled()
136+
restore()
135137
})
136138

137139
test('functional themes receive outer theme', () => {

0 commit comments

Comments
 (0)