Skip to content

Commit 5c7f02b

Browse files
committed
fix tests
1 parent ed0d7f1 commit 5c7f02b

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

packages/jest/test/__snapshots__/react-enzyme.test.js.snap

+10-29
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,13 @@ exports[`enzyme mount theming 1`] = `
250250
border: 2px solid red;
251251
}
252252
253+
.emotion-2 {
254+
color: blue;
255+
border: 2px solid blue;
256+
}
257+
253258
<div>
254-
<Button
255-
theme={
256-
{
257-
"main": "red",
258-
}
259-
}
260-
>
259+
<Button>
261260
<button
262261
className="emotion-0 emotion-1"
263262
>
@@ -271,15 +270,9 @@ exports[`enzyme mount theming 1`] = `
271270
}
272271
}
273272
>
274-
<Button
275-
theme={
276-
{
277-
"main": "red",
278-
}
279-
}
280-
>
273+
<Button>
281274
<button
282-
className="emotion-0 emotion-1"
275+
className="emotion-2 emotion-1"
283276
>
284277
Themed
285278
</button>
@@ -664,13 +657,7 @@ exports[`enzyme shallow styled with css prop 1`] = `
664657

665658
exports[`enzyme shallow theming 1`] = `
666659
<div>
667-
<Button
668-
theme={
669-
{
670-
"main": "red",
671-
}
672-
}
673-
>
660+
<Button>
674661
Normal
675662
</Button>
676663
<ThemeProvider
@@ -680,13 +667,7 @@ exports[`enzyme shallow theming 1`] = `
680667
}
681668
}
682669
>
683-
<Button
684-
theme={
685-
{
686-
"main": "red",
687-
}
688-
}
689-
>
670+
<Button>
690671
Themed
691672
</Button>
692673
</ThemeProvider>

packages/jest/test/react-enzyme.test.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,33 @@ import 'test-utils/enzyme-env'
33

44
import jestInCase from 'jest-in-case'
55
import * as enzyme from 'enzyme'
6-
import { css, jsx, ThemeProvider } from '@emotion/react'
6+
import {
7+
__unsafe_useEmotionCache,
8+
css,
9+
jsx,
10+
ThemeProvider,
11+
EmotionCache
12+
} from '@emotion/react'
713
import styled from '@emotion/styled'
814
import React from 'react'
915
import toJson from 'enzyme-to-json'
1016

1117
import { matchers } from '@emotion/jest'
1218
import * as serializer from '@emotion/jest/enzyme-serializer'
1319

20+
afterEach(() => {
21+
let cache
22+
function GetCache() {
23+
cache = __unsafe_useEmotionCache()
24+
return null
25+
}
26+
enzyme.shallow(<GetCache />)
27+
28+
cache.registered = {}
29+
cache.inserted = {}
30+
cache.sheet.flush()
31+
})
32+
1433
const isReact16 = React.version.split('.')[0] === '16'
1534

1635
expect.extend(matchers)

packages/react/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type {
3030
export { ThemeContext, useTheme, ThemeProvider, withTheme } from './theming'
3131
export type { Theme, ThemeProviderProps, WithTheme } from './theming'
3232
export { default as css } from './css'
33-
export type { DistributiveOmit, PropsOf } from './types'
33+
export type { DistributiveOmit } from './types'
3434

3535
declare const global: Record<string, unknown>
3636
declare const jest: unknown

packages/styled/test/__snapshots__/index.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ exports[`styled nested 1`] = `
200200
<div
201201
className="emotion-0 emotion-1"
202202
>
203-
hello
203+
hello
204204
<h1
205205
className="emotion-2 emotion-3"
206206
>
@@ -360,7 +360,7 @@ exports[`styled withComponent will replace tags but keep styling classes 1`] = `
360360
My Title
361361
</h1>
362362
<h2
363-
className="emotion-2 emotion-3"
363+
className="emotion-2 emotion-19"
364364
>
365365
My Subtitle
366366
</h2>

0 commit comments

Comments
 (0)