From e44074e67f7f651d336ceb969c05c6fded27ef00 Mon Sep 17 00:00:00 2001 From: Piotr Monwid-Olechnowicz Date: Thu, 17 Oct 2024 14:51:17 +0200 Subject: [PATCH] test: fix tests after version bumps --- packages/color-modes/test/index.tsx | 12 +- packages/css/package.json | 4 +- packages/css/test/index.ts | 3 + .../global/test/__snapshots__/index.tsx.snap | 15 - packages/prism/src/index.tsx | 17 +- .../prism/test/__snapshots__/index.tsx.snap | 12 +- .../tailwind/test/__snapshots__/test.ts.snap | 356 ++++++++++-------- packages/theme-ui/test/color-modes.tsx | 12 +- packages/typography/package.json | 2 +- pnpm-lock.yaml | 19 +- 10 files changed, 250 insertions(+), 202 deletions(-) diff --git a/packages/color-modes/test/index.tsx b/packages/color-modes/test/index.tsx index 96d50ae45..e05e7323b 100644 --- a/packages/color-modes/test/index.tsx +++ b/packages/color-modes/test/index.tsx @@ -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 = () => { @@ -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.", @@ -937,6 +934,7 @@ test('warns when localStorage is disabled', () => { ] `) + spy.mockClear() restoreConsole() }) diff --git a/packages/css/package.json b/packages/css/package.json index 03f4b5bc4..56da0de77 100644 --- a/packages/css/package.json +++ b/packages/css/package.json @@ -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" }, diff --git a/packages/css/test/index.ts b/packages/css/test/index.ts index 3eb4b73cc..8c24a5681 100644 --- a/packages/css/test/index.ts +++ b/packages/css/test/index.ts @@ -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) diff --git a/packages/global/test/__snapshots__/index.tsx.snap b/packages/global/test/__snapshots__/index.tsx.snap index 15fe640dd..906e81170 100644 --- a/packages/global/test/__snapshots__/index.tsx.snap +++ b/packages/global/test/__snapshots__/index.tsx.snap @@ -49,21 +49,6 @@ exports[`renders global styles 1`] = ` data-s="" > - @font-face{font-family:some-name;} - - - diff --git a/packages/prism/src/index.tsx b/packages/prism/src/index.tsx index f46807adc..8a757d84f 100644 --- a/packages/prism/src/index.tsx +++ b/packages/prism/src/index.tsx @@ -131,12 +131,17 @@ export default function ThemeUIPrism({ } return (
- {line.map((token, key) => ( - - ))} + {line.map((token, key) => { + return ( + + ) + })}
) })} diff --git a/packages/prism/test/__snapshots__/index.tsx.snap b/packages/prism/test/__snapshots__/index.tsx.snap index 9f72731a1..3eacb6f07 100644 --- a/packages/prism/test/__snapshots__/index.tsx.snap +++ b/packages/prism/test/__snapshots__/index.tsx.snap @@ -2,7 +2,7 @@ exports[`highlight start and end 1`] = `