Skip to content

Commit a4fe488

Browse files
committed
Add simple snapshot tests for new views
Required mocking style imports.
1 parent 656ec78 commit a4fe488

File tree

4 files changed

+199
-0
lines changed

4 files changed

+199
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {}

packages/webui/jest.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'sha.js': 'sha.js',
1111
'meteor/(.*)': '<rootDir>/src/meteor/$1',
1212
'(.+)\\.js$': '$1',
13+
'\\.(css|scss|sass)$': '<rootDir>/__mocks__/styleMock.js',
1314
},
1415
transform: {
1516
'^.+\\.(ts|tsx)$': [
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { render } from '@testing-library/react'
2+
import '@testing-library/jest-dom'
3+
import { BrowserRouter } from 'react-router-dom'
4+
import { ClockViewIndex } from '../ClockViewIndex'
5+
import { MultiviewScreen } from '../MultiviewScreen'
6+
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
7+
8+
jest.mock('react-bootstrap/esm/Container', () => ({
9+
__esModule: true,
10+
default: ({ children, ...props }: any) => <div {...props}>{children}</div>,
11+
}))
12+
13+
jest.mock('react-i18next', () => ({
14+
useTranslation: () => ({
15+
t: (str: string, options?: Record<string, any>) => {
16+
if (options?.studioId) {
17+
return str.replace('{{studioId}}', options.studioId)
18+
}
19+
return str
20+
},
21+
i18n: {
22+
changeLanguage: () => Promise.resolve(),
23+
},
24+
}),
25+
}))
26+
27+
describe('ClockViewIndex', () => {
28+
it('renders with studio ID', () => {
29+
const studioId = protectString('studio0')
30+
const { container } = render(
31+
<BrowserRouter>
32+
<ClockViewIndex studioId={studioId} />
33+
</BrowserRouter>
34+
)
35+
36+
expect(container).toMatchSnapshot()
37+
})
38+
})
39+
40+
describe('MultiviewScreen', () => {
41+
it('renders with studio ID', () => {
42+
const studioId = protectString('studio0')
43+
const { container } = render(<MultiviewScreen studioId={studioId} />)
44+
45+
expect(container).toMatchSnapshot()
46+
})
47+
})
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ClockViewIndex renders with studio ID 1`] = `
4+
<div>
5+
<div
6+
class="header-clear"
7+
>
8+
<section
9+
class="mt-5 mx-5"
10+
>
11+
<header
12+
class="my-2"
13+
>
14+
<h1>
15+
Available Views for Studio studio0
16+
</h1>
17+
</header>
18+
<section
19+
class="my-5"
20+
>
21+
<ul>
22+
<li>
23+
<a
24+
href="/countdowns/studio0/presenter"
25+
>
26+
Presenter Screen
27+
</a>
28+
</li>
29+
<li>
30+
<a
31+
href="/countdowns/studio0/director"
32+
>
33+
Director Screen
34+
</a>
35+
</li>
36+
<li>
37+
<a
38+
href="/countdowns/studio0/overlay"
39+
>
40+
Overlay Screen
41+
</a>
42+
</li>
43+
<li>
44+
<a
45+
href="/countdowns/studio0/camera"
46+
>
47+
Camera Screen
48+
</a>
49+
</li>
50+
<li>
51+
<a
52+
href="/prompter/studio0"
53+
>
54+
Prompter
55+
</a>
56+
</li>
57+
<li>
58+
<a
59+
href="/activeRundown/studio0"
60+
>
61+
Active Rundown
62+
</a>
63+
</li>
64+
<li>
65+
<a
66+
href="/countdowns/studio0/multiview"
67+
>
68+
Multiview (All Screens)
69+
</a>
70+
</li>
71+
</ul>
72+
</section>
73+
</section>
74+
</div>
75+
</div>
76+
`;
77+
78+
exports[`MultiviewScreen renders with studio ID 1`] = `
79+
<div>
80+
<div
81+
class="multiview-grid"
82+
>
83+
<div
84+
class="multiview-item multiview-presenter"
85+
>
86+
<iframe
87+
src="/countdowns/studio0/presenter"
88+
title="Presenter Screen"
89+
/>
90+
<div
91+
class="multiview-label"
92+
>
93+
Presenter Screen
94+
</div>
95+
</div>
96+
<div
97+
class="multiview-item multiview-director"
98+
>
99+
<iframe
100+
src="/countdowns/studio0/director"
101+
title="Director Screen"
102+
/>
103+
<div
104+
class="multiview-label"
105+
>
106+
Director Screen
107+
</div>
108+
</div>
109+
<div
110+
class="multiview-item multiview-prompter"
111+
>
112+
<iframe
113+
src="/prompter/studio0"
114+
title="Prompter"
115+
/>
116+
<div
117+
class="multiview-label"
118+
>
119+
Prompter
120+
</div>
121+
</div>
122+
<div
123+
class="multiview-item multiview-overlay"
124+
>
125+
<iframe
126+
src="/countdowns/studio0/overlay"
127+
title="Overlay Screen"
128+
/>
129+
<div
130+
class="multiview-label"
131+
>
132+
Overlay Screen
133+
</div>
134+
</div>
135+
<div
136+
class="multiview-item multiview-camera"
137+
>
138+
<iframe
139+
src="/countdowns/studio0/camera"
140+
title="Camera Screen"
141+
/>
142+
<div
143+
class="multiview-label"
144+
>
145+
Camera Screen
146+
</div>
147+
</div>
148+
</div>
149+
</div>
150+
`;

0 commit comments

Comments
 (0)