Skip to content

Commit

Permalink
test: fix tests after version bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus committed Oct 17, 2024
1 parent 14f1620 commit e44074e
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 202 deletions.
12 changes: 5 additions & 7 deletions packages/color-modes/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -903,12 +903,11 @@ test('colorMode accepts function from previous state to new one', () => {
test('warns when localStorage is disabled', () => {
const restoreConsole = mockConsole()

const localStorage = window.localStorage
Object.defineProperty(window, 'localStorage', {
get: jest.fn(() => {
const spy = jest
.spyOn(Storage.prototype, 'getItem')
.mockImplementation(() => {
throw new Error('SecurityError: The operation is insecure.')
}),
})
})

let mode = ''
const Consumer = () => {
Expand All @@ -927,8 +926,6 @@ test('warns when localStorage is disabled', () => {

expect(mode).toBe(undefined)

Object.defineProperty(window, 'localStorage', { value: localStorage })

expect((console.warn as jest.Mock).mock.calls[0]).toMatchInlineSnapshot(`
[
"localStorage is disabled and color mode might not work as expected.",
Expand All @@ -937,6 +934,7 @@ test('warns when localStorage is disabled', () => {
]
`)

spy.mockClear()
restoreConsole()
})

Expand Down
4 changes: 2 additions & 2 deletions packages/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
"access": "public"
},
"dependencies": {
"csstype": "^3.0.10"
"csstype": "3.0.10"
},
"peerDependencies": {
"@emotion/react": "^11.11.1"
},
"devDependencies": {
"@emotion/react": "^11.13.3",
"@emotion/react": "^11.11.1",
"@theme-ui/test-utils": "workspace:^",
"@types/react": "^18.2.12"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/css/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,11 @@ test('supports vendor properties', () => {
test('omits empty values', () => {
expect(
css({
// @ts-ignore TS2873
color: false && 'blue',
// @ts-ignore TS2873
backgroundColor: undefined && 'whitesmoke',
// @ts-ignore TS2873
textDecoration: null && 'underline',
border: '1px solid black',
})(theme)
Expand Down
15 changes: 0 additions & 15 deletions packages/global/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ exports[`renders global styles 1`] = `
data-s=""
>
@font-face{font-family:some-name;}
</style>
<style
data-emotion="css-global"
data-s=""
>
body{font-family:Georgia,serif;margin:0;}
</style>
<style
data-emotion="css-global"
data-s=""
>
h1{color:salmon;}
</style>
</head>
<body>
Expand Down
17 changes: 11 additions & 6 deletions packages/prism/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,17 @@ export default function ThemeUIPrism({
}
return (
<div {...lineProps}>
{line.map((token, key) => (
<span
{...getTokenProps({ token, key })}
sx={token.empty ? { display: 'inline-block' } : undefined}
/>
))}
{line.map((token, key) => {
return (
<span
{...getTokenProps({ token, key })}
key={key}
sx={
token.empty ? { display: 'inline-block' } : undefined
}
/>
)
})}
</div>
)
})}
Expand Down
12 changes: 6 additions & 6 deletions packages/prism/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`highlight start and end 1`] = `
<pre
className="language-js prism-code language-javascript emotion-0"
className="language-js prism-code language-javascript css-1avyp1d"
style={{}}
>
<div
Expand Down Expand Up @@ -88,7 +88,7 @@ exports[`highlight start and end 1`] = `

exports[`highlights inline comment 1`] = `
<pre
className="language-js prism-code language-javascript emotion-0"
className="language-js prism-code language-javascript css-1avyp1d"
style={{}}
>
<div
Expand Down Expand Up @@ -262,7 +262,7 @@ exports[`multiple highlights start and end 1`] = `

exports[`no highlight 1`] = `
<pre
className="language-js prism-code language-javascript emotion-0"
className="language-js prism-code language-javascript css-1avyp1d"
style={{}}
>
<div
Expand Down Expand Up @@ -309,7 +309,7 @@ exports[`no highlight 1`] = `

exports[`renders a code block 1`] = `
<pre
className="language-js prism-code language-javascript emotion-0"
className="language-js prism-code language-javascript css-1avyp1d"
style={{}}
>
<div
Expand Down Expand Up @@ -351,7 +351,7 @@ exports[`renders a code block 1`] = `

exports[`renders with no className 1`] = `
<pre
className=" prism-code language- emotion-0"
className="prism-code language- css-1avyp1d"
style={{}}
>
<div
Expand All @@ -368,7 +368,7 @@ exports[`renders with no className 1`] = `

exports[`renders with other languages 1`] = `
<pre
className="language-php prism-code language-php emotion-0"
className="language-php prism-code language-php css-1avyp1d"
style={{}}
>
<div
Expand Down
Loading

0 comments on commit e44074e

Please sign in to comment.