Skip to content

Commit f833c7e

Browse files
Update failing unit tests
- Add babel plugin to handle Jest import of SVG. Without plugin the test fails with a require.context() is undefined - Update snapshot tests that have changed - Removed globals from .eslintrc.js that were needed prior to migrating from Mocha and Chai to Jest Signed-off-by: Derick Montague <[email protected]> Change-Id: Ibd01d2e629b5ecb47d072e277e4e9b5ae5c5f001
1 parent f6bd4c6 commit f833c7e

File tree

7 files changed

+597
-480
lines changed

7 files changed

+597
-480
lines changed

.eslintrc.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ module.exports = {
1919
parserOptions: {
2020
parser: 'babel-eslint',
2121
},
22-
globals: {
23-
expect: true,
24-
sinon: true,
25-
},
2622
overrides: [
2723
{
2824
files: [

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
module.exports = {
22
presets: [['@vue/cli-plugin-babel/preset', { useBuiltIns: 'entry' }]],
3+
env: {
4+
test: {
5+
plugins: ['transform-require-context'],
6+
},
7+
},
38
};

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@vue/eslint-config-prettier": "5.0.0",
4545
"@vue/test-utils": "1.1.0",
4646
"babel-eslint": "10.1.0",
47+
"babel-plugin-transform-require-context": "0.1.1",
4748
"check-node-version": "4.0.3",
4849
"compression-webpack-plugin": "6.0.3",
4950
"eslint": "7.11.0",

tests/unit/AppHeader.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('AppHeader.vue', () => {
1212
const actions = {
1313
'global/getHostStatus': jest.fn(),
1414
'eventLog/getEventLogData': jest.fn(),
15+
'authentication/resetStoreState': jest.fn(),
1516
};
1617

1718
const store = new Vuex.Store({ actions });

tests/unit/__snapshots__/AppHeader.spec.js.snap

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,33 @@ exports[`AppHeader.vue should render correctly 1`] = `
2323
aria-hidden="true"
2424
class="nav-trigger"
2525
id="app-header-trigger"
26-
title="Open navigation"
2726
type="button"
2827
variant="link"
2928
>
3029
<!---->
3130
3231
<svg
33-
aria-hidden="true"
32+
fill="currentColor"
3433
focusable="false"
3534
height="20"
3635
preserveAspectRatio="xMidYMid meet"
37-
style="will-change: transform;"
36+
role="img"
37+
title="appHeader.titleShowNavigation"
3838
viewBox="0 0 20 20"
3939
width="20"
4040
xmlns="http://www.w3.org/2000/svg"
4141
>
42+
<title>
43+
appHeader.titleShowNavigation
44+
</title>
4245
<path
43-
d="M2 14.8h16V16H2zm0-3.6h16v1.2H2zm0-3.6h16v1.2H2zM2 4h16v1.2H2z"
46+
d="M2 14.8H18V16H2zM2 11.2H18V12.399999999999999H2zM2 7.6H18V8.799999999999999H2zM2 4H18V5.2H2z"
4447
/>
4548
</svg>
4649
</b-button>
4750
4851
<b-navbar-nav>
49-
<b-nav-item
52+
<b-navbar-brand
5053
data-test-id="appHeader-container-overview"
5154
to="/"
5255
>
@@ -55,7 +58,7 @@ exports[`AppHeader.vue should render correctly 1`] = `
5558
class="header-logo"
5659
src="@/assets/images/logo-header.svg"
5760
/>
58-
</b-nav-item>
61+
</b-navbar-brand>
5962
</b-navbar-nav>
6063
6164
<b-navbar-nav
@@ -70,19 +73,19 @@ exports[`AppHeader.vue should render correctly 1`] = `
7073
>
7174
<svg
7275
aria-hidden="true"
76+
fill="currentColor"
7377
focusable="false"
7478
height="20"
7579
preserveAspectRatio="xMidYMid meet"
76-
style="will-change: transform;"
7780
viewBox="0 0 20 20"
7881
width="20"
7982
xmlns="http://www.w3.org/2000/svg"
8083
>
8184
<path
82-
d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm3.5 13.5l-8-8 1-1 8 8-1 1z"
85+
d="M10,1c-5,0-9,4-9,9s4,9,9,9s9-4,9-9S15,1,10,1z M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z"
8386
/>
8487
<path
85-
d="M13.5 14.5l-8-8 1-1 8 8-1 1z"
88+
d="M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z"
8689
data-icon-path="inner-path"
8790
opacity="0"
8891
/>
@@ -102,19 +105,19 @@ exports[`AppHeader.vue should render correctly 1`] = `
102105
>
103106
<svg
104107
aria-hidden="true"
108+
fill="currentColor"
105109
focusable="false"
106110
height="20"
107111
preserveAspectRatio="xMidYMid meet"
108-
style="will-change: transform;"
109112
viewBox="0 0 20 20"
110113
width="20"
111114
xmlns="http://www.w3.org/2000/svg"
112115
>
113116
<path
114-
d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm3.5 13.5l-8-8 1-1 8 8-1 1z"
117+
d="M10,1c-5,0-9,4-9,9s4,9,9,9s9-4,9-9S15,1,10,1z M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z"
115118
/>
116119
<path
117-
d="M13.5 14.5l-8-8 1-1 8 8-1 1z"
120+
d="M13.5,14.5l-8-8l1-1l8,8L13.5,14.5z"
118121
data-icon-path="inner-path"
119122
opacity="0"
120123
/>
@@ -134,17 +137,21 @@ exports[`AppHeader.vue should render correctly 1`] = `
134137
variant="link"
135138
>
136139
<svg
137-
aria-hidden="true"
140+
fill="currentColor"
138141
focusable="false"
139142
height="20"
140143
preserveAspectRatio="xMidYMid meet"
141-
style="will-change: transform;"
144+
role="img"
145+
title="appHeader.titleRefresh"
142146
viewBox="0 0 32 32"
143147
width="20"
144148
xmlns="http://www.w3.org/2000/svg"
145149
>
150+
<title>
151+
appHeader.titleRefresh
152+
</title>
146153
<path
147-
d="M12 10H6.78A11 11 0 0 1 27 16h2A13 13 0 0 0 6 7.68V4H4v8h8zm8 12h5.22A11 11 0 0 1 5 16H3a13 13 0 0 0 23 8.32V28h2v-8h-8z"
154+
d="M12 10H6.78A11 11 0 0127 16h2A13 13 0 006 7.68V4H4v8h8zM20 22h5.22A11 11 0 015 16H3a13 13 0 0023 8.32V28h2V20H20z"
148155
/>
149156
</svg>
150157
@@ -187,15 +194,17 @@ exports[`AppHeader.vue should render correctly 1`] = `
187194
</b-navbar>
188195
</header>
189196
190-
<b-progress
191-
height="0.4rem"
197+
<transition-stub
198+
name="fade"
192199
>
193-
<b-progress-bar
194-
animated=""
195-
aria-label="global.ariaLabel.progressBar"
196-
striped=""
197-
value="0"
198-
/>
199-
</b-progress>
200+
<b-progress>
201+
<b-progress-bar
202+
animated=""
203+
aria-label="global.ariaLabel.progressBar"
204+
striped=""
205+
value="0"
206+
/>
207+
</b-progress>
208+
</transition-stub>
200209
</div>
201210
`;

0 commit comments

Comments
 (0)