Skip to content

Commit 6fb66e0

Browse files
authored
tests: resolves failing tests in supplemental 7 demo (#837)
Signed-off-by: Anthony D. Mays <[email protected]>
1 parent a8df9d4 commit 6fb66e0

File tree

5 files changed

+107
-114
lines changed

5 files changed

+107
-114
lines changed

supplemental7/a11y/__tests__/setup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ const localStorageMock = {
2424
};
2525
global.localStorage = localStorageMock as any;
2626

27+
// Mock IntersectionObserver to prevent async state updates in tests
28+
global.IntersectionObserver = class IntersectionObserver {
29+
constructor() {}
30+
disconnect() {}
31+
observe() {}
32+
takeRecords() {
33+
return [];
34+
}
35+
unobserve() {}
36+
} as unknown as typeof IntersectionObserver;
37+

supplemental7/a11y/app/components/CodeBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
4-
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
4+
import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism';
55

66
interface CodeBlockProps {
77
code: string;

supplemental7/a11y/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const customJestConfig = {
1111
testEnvironment: 'jest-environment-jsdom',
1212
moduleNameMapper: {
1313
'^@/(.*)$': '<rootDir>/$1',
14+
'^react-syntax-highlighter/dist/esm/(.*)$': 'react-syntax-highlighter/dist/cjs/$1',
1415
},
1516
testMatch: ['**/__tests__/**/*.test.[jt]s?(x)'],
1617
collectCoverageFrom: [

0 commit comments

Comments
 (0)