Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 9, 2024
1 parent ed0d7f1 commit 5c7f02b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
39 changes: 10 additions & 29 deletions packages/jest/test/__snapshots__/react-enzyme.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,13 @@ exports[`enzyme mount theming 1`] = `
border: 2px solid red;
}
.emotion-2 {
color: blue;
border: 2px solid blue;
}
<div>
<Button
theme={
{
"main": "red",
}
}
>
<Button>
<button
className="emotion-0 emotion-1"
>
Expand All @@ -271,15 +270,9 @@ exports[`enzyme mount theming 1`] = `
}
}
>
<Button
theme={
{
"main": "red",
}
}
>
<Button>
<button
className="emotion-0 emotion-1"
className="emotion-2 emotion-1"
>
Themed
</button>
Expand Down Expand Up @@ -664,13 +657,7 @@ exports[`enzyme shallow styled with css prop 1`] = `

exports[`enzyme shallow theming 1`] = `
<div>
<Button
theme={
{
"main": "red",
}
}
>
<Button>
Normal
</Button>
<ThemeProvider
Expand All @@ -680,13 +667,7 @@ exports[`enzyme shallow theming 1`] = `
}
}
>
<Button
theme={
{
"main": "red",
}
}
>
<Button>
Themed
</Button>
</ThemeProvider>
Expand Down
21 changes: 20 additions & 1 deletion packages/jest/test/react-enzyme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,33 @@ import 'test-utils/enzyme-env'

import jestInCase from 'jest-in-case'
import * as enzyme from 'enzyme'
import { css, jsx, ThemeProvider } from '@emotion/react'
import {
__unsafe_useEmotionCache,
css,
jsx,
ThemeProvider,
EmotionCache
} from '@emotion/react'
import styled from '@emotion/styled'
import React from 'react'
import toJson from 'enzyme-to-json'

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

afterEach(() => {
let cache
function GetCache() {
cache = __unsafe_useEmotionCache()
return null
}
enzyme.shallow(<GetCache />)

cache.registered = {}
cache.inserted = {}
cache.sheet.flush()
})

const isReact16 = React.version.split('.')[0] === '16'

expect.extend(matchers)
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type {
export { ThemeContext, useTheme, ThemeProvider, withTheme } from './theming'
export type { Theme, ThemeProviderProps, WithTheme } from './theming'
export { default as css } from './css'
export type { DistributiveOmit, PropsOf } from './types'
export type { DistributiveOmit } from './types'

declare const global: Record<string, unknown>
declare const jest: unknown
Expand Down
4 changes: 2 additions & 2 deletions packages/styled/test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ exports[`styled nested 1`] = `
<div
className="emotion-0 emotion-1"
>
hello
hello
<h1
className="emotion-2 emotion-3"
>
Expand Down Expand Up @@ -360,7 +360,7 @@ exports[`styled withComponent will replace tags but keep styling classes 1`] = `
My Title
</h1>
<h2
className="emotion-2 emotion-3"
className="emotion-2 emotion-19"
>
My Subtitle
</h2>
Expand Down

0 comments on commit 5c7f02b

Please sign in to comment.