Skip to content

Commit 3ef2280

Browse files
committed
Add simple snapshot tests for new views
Required mocking style imports.
1 parent 542c392 commit 3ef2280

File tree

4 files changed

+200
-0
lines changed

4 files changed

+200
-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: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
fluid="true"
8+
>
9+
<section
10+
class="mt-5 mx-5"
11+
>
12+
<header
13+
class="my-2"
14+
>
15+
<h1>
16+
Available Views for Studio studio0
17+
</h1>
18+
</header>
19+
<section
20+
class="my-5"
21+
>
22+
<ul>
23+
<li>
24+
<a
25+
href="/countdowns/studio0/presenter"
26+
>
27+
Presenter Screen
28+
</a>
29+
</li>
30+
<li>
31+
<a
32+
href="/countdowns/studio0/director"
33+
>
34+
Director Screen
35+
</a>
36+
</li>
37+
<li>
38+
<a
39+
href="/countdowns/studio0/overlay"
40+
>
41+
Overlay Screen
42+
</a>
43+
</li>
44+
<li>
45+
<a
46+
href="/countdowns/studio0/camera"
47+
>
48+
Camera Screen
49+
</a>
50+
</li>
51+
<li>
52+
<a
53+
href="/prompter/studio0"
54+
>
55+
Prompter
56+
</a>
57+
</li>
58+
<li>
59+
<a
60+
href="/activeRundown/studio0"
61+
>
62+
Active Rundown
63+
</a>
64+
</li>
65+
<li>
66+
<a
67+
href="/countdowns/studio0/multiview"
68+
>
69+
Multiview (All Screens)
70+
</a>
71+
</li>
72+
</ul>
73+
</section>
74+
</section>
75+
</div>
76+
</div>
77+
`;
78+
79+
exports[`MultiviewScreen renders with studio ID 1`] = `
80+
<div>
81+
<div
82+
class="multiview-grid"
83+
>
84+
<div
85+
class="multiview-item multiview-presenter"
86+
>
87+
<iframe
88+
src="/countdowns/studio0/presenter"
89+
title="Presenter Screen"
90+
/>
91+
<div
92+
class="multiview-label"
93+
>
94+
Presenter Screen
95+
</div>
96+
</div>
97+
<div
98+
class="multiview-item multiview-director"
99+
>
100+
<iframe
101+
src="/countdowns/studio0/director"
102+
title="Director Screen"
103+
/>
104+
<div
105+
class="multiview-label"
106+
>
107+
Director Screen
108+
</div>
109+
</div>
110+
<div
111+
class="multiview-item multiview-prompter"
112+
>
113+
<iframe
114+
src="/prompter/studio0"
115+
title="Prompter"
116+
/>
117+
<div
118+
class="multiview-label"
119+
>
120+
Prompter
121+
</div>
122+
</div>
123+
<div
124+
class="multiview-item multiview-overlay"
125+
>
126+
<iframe
127+
src="/countdowns/studio0/overlay"
128+
title="Overlay Screen"
129+
/>
130+
<div
131+
class="multiview-label"
132+
>
133+
Overlay Screen
134+
</div>
135+
</div>
136+
<div
137+
class="multiview-item multiview-camera"
138+
>
139+
<iframe
140+
src="/countdowns/studio0/camera"
141+
title="Camera Screen"
142+
/>
143+
<div
144+
class="multiview-label"
145+
>
146+
Camera Screen
147+
</div>
148+
</div>
149+
</div>
150+
</div>
151+
`;

0 commit comments

Comments
 (0)