@rancher/shell 0.3.22 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +3 -0
- package/components/SortableTable/paging.js +10 -0
- package/components/form/GitPicker.vue +16 -0
- package/components/form/SelectOrCreateAuthSecret.vue +9 -3
- package/edit/resources.cattle.io.backup.vue +3 -1
- package/edit/resources.cattle.io.restore.vue +3 -1
- package/package.json +1 -1
- package/rancher-components/BadgeState/BadgeState.vue +1 -5
- package/rancher-components/Banner/Banner.test.ts +1 -51
- package/rancher-components/Banner/Banner.vue +53 -134
- package/rancher-components/Card/Card.vue +7 -24
- package/rancher-components/Form/Checkbox/Checkbox.test.ts +29 -20
- package/rancher-components/Form/Checkbox/Checkbox.vue +20 -45
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +8 -2
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +10 -22
- package/rancher-components/Form/Radio/RadioButton.vue +13 -30
- package/rancher-components/Form/Radio/RadioGroup.vue +7 -26
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +6 -7
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.test.ts +38 -25
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +11 -23
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +5 -19
- package/rancher-components/StringList/StringList.test.ts +49 -453
- package/rancher-components/StringList/StringList.vue +58 -92
- package/types/shell/index.d.ts +15 -9
- package/utils/__tests__/formatter.test.ts +77 -0
- package/utils/formatter.js +11 -0
- package/vue.config.js +6 -2
- package/rancher-components/Card/Card.test.ts +0 -37
- package/rancher-components/Form/Radio/RadioButton.test.ts +0 -31
- package/yarn-error.log +0 -200
package/babel.config.js
CHANGED
|
@@ -103,6 +103,16 @@ export default {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
this.setPage(page);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
getPageByRow(rowId, getRowId = (x) => x) {
|
|
109
|
+
const pos = this.filteredRows.map(getRowId).indexOf(rowId);
|
|
110
|
+
|
|
111
|
+
if (pos === -1) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return Math.ceil(pos / this.perPage);
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
};
|
|
@@ -347,6 +347,20 @@ export default Vue.extend<Data, any, any, any>({
|
|
|
347
347
|
branchesRules() {
|
|
348
348
|
return this.hasError.branch ? this.t(`gitPicker.${ this.type }.errors.noBranch`) : null;
|
|
349
349
|
},
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Show the page where the commit is, if any
|
|
353
|
+
*/
|
|
354
|
+
onCommitsTableMounted() {
|
|
355
|
+
const commitId = this.$route.query?.commit;
|
|
356
|
+
|
|
357
|
+
if (commitId) {
|
|
358
|
+
const table = this.$refs.commitsTable;
|
|
359
|
+
const page = table.getPageByRow(commitId, ({ commitId }: commit) => commitId);
|
|
360
|
+
|
|
361
|
+
table.setPage(page);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
350
364
|
},
|
|
351
365
|
});
|
|
352
366
|
</script>
|
|
@@ -413,6 +427,7 @@ export default Vue.extend<Data, any, any, any>({
|
|
|
413
427
|
class="commits-table mt-20"
|
|
414
428
|
>
|
|
415
429
|
<SortableTable
|
|
430
|
+
ref="commitsTable"
|
|
416
431
|
:rows="preparedCommits"
|
|
417
432
|
:headers="commitHeaders"
|
|
418
433
|
mode="view"
|
|
@@ -422,6 +437,7 @@ export default Vue.extend<Data, any, any, any>({
|
|
|
422
437
|
:table-actions="false"
|
|
423
438
|
:row-actions="false"
|
|
424
439
|
:rows-per-page="10"
|
|
440
|
+
@hook:mounted="onCommitsTableMounted"
|
|
425
441
|
>
|
|
426
442
|
<template #cell:index="{row}">
|
|
427
443
|
<RadioButton
|
|
@@ -226,10 +226,16 @@ export default {
|
|
|
226
226
|
|
|
227
227
|
return true;
|
|
228
228
|
}).map((x) => {
|
|
229
|
+
const {
|
|
230
|
+
dataPreview, subTypeDisplay, metadata, id
|
|
231
|
+
} = x;
|
|
232
|
+
|
|
233
|
+
const label = subTypeDisplay && dataPreview ? `${ metadata.name } (${ subTypeDisplay }: ${ dataPreview })` : `${ metadata.name } (${ subTypeDisplay })`;
|
|
234
|
+
|
|
229
235
|
return {
|
|
230
|
-
label
|
|
231
|
-
group:
|
|
232
|
-
value:
|
|
236
|
+
label,
|
|
237
|
+
group: metadata.namespace,
|
|
238
|
+
value: id,
|
|
233
239
|
};
|
|
234
240
|
});
|
|
235
241
|
|
|
@@ -16,6 +16,8 @@ import { allHash } from '@shell/utils/promise';
|
|
|
16
16
|
import { NAMESPACE, _VIEW } from '@shell/config/query-params';
|
|
17
17
|
import { sortBy } from '@shell/utils/sort';
|
|
18
18
|
import { get } from '@shell/utils/object';
|
|
19
|
+
import { formatEncryptionSecretNames } from '@shell/utils/formatter';
|
|
20
|
+
|
|
19
21
|
export default {
|
|
20
22
|
|
|
21
23
|
components: {
|
|
@@ -108,7 +110,7 @@ export default {
|
|
|
108
110
|
},
|
|
109
111
|
|
|
110
112
|
encryptionSecretNames() {
|
|
111
|
-
return this.allSecrets
|
|
113
|
+
return formatEncryptionSecretNames(this.allSecrets, this.chartNamespace);
|
|
112
114
|
},
|
|
113
115
|
|
|
114
116
|
storageOptions() {
|
|
@@ -13,6 +13,8 @@ import { SECRET, BACKUP_RESTORE, CATALOG } from '@shell/config/types';
|
|
|
13
13
|
import { allHash } from '@shell/utils/promise';
|
|
14
14
|
import { get } from '@shell/utils/object';
|
|
15
15
|
import { _CREATE } from '@shell/config/query-params';
|
|
16
|
+
import { formatEncryptionSecretNames } from '@shell/utils/formatter';
|
|
17
|
+
|
|
16
18
|
export default {
|
|
17
19
|
|
|
18
20
|
components: {
|
|
@@ -93,7 +95,7 @@ export default {
|
|
|
93
95
|
},
|
|
94
96
|
|
|
95
97
|
encryptionSecretNames() {
|
|
96
|
-
return this.allSecrets
|
|
98
|
+
return formatEncryptionSecretNames(this.allSecrets, this.chartNamespace);
|
|
97
99
|
},
|
|
98
100
|
|
|
99
101
|
isEncrypted() {
|
package/package.json
CHANGED
|
@@ -60,11 +60,7 @@ export default Vue.extend({
|
|
|
60
60
|
|
|
61
61
|
<template>
|
|
62
62
|
<span :class="{'badge-state': true, [bg]: true}">
|
|
63
|
-
<i
|
|
64
|
-
v-if="icon"
|
|
65
|
-
class="icon"
|
|
66
|
-
:class="{[icon]: true, 'mr-5': !!msg}"
|
|
67
|
-
/>{{ msg }}
|
|
63
|
+
<i v-if="icon" class="icon" :class="{[icon]: true, 'mr-5': !!msg}" />{{ msg }}
|
|
68
64
|
</span>
|
|
69
65
|
</template>
|
|
70
66
|
|
|
@@ -1,63 +1,13 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
2
|
import { Banner } from './index';
|
|
3
|
-
import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
|
|
4
3
|
|
|
5
4
|
describe('component: Banner', () => {
|
|
6
5
|
it('should display text based on label', () => {
|
|
7
6
|
const label = 'test';
|
|
8
|
-
const wrapper = mount(
|
|
9
|
-
Banner,
|
|
10
|
-
{
|
|
11
|
-
directives: { cleanHtmlDirective },
|
|
12
|
-
propsData: { label }
|
|
13
|
-
});
|
|
7
|
+
const wrapper = mount(Banner, { propsData: { label } });
|
|
14
8
|
|
|
15
9
|
const element = wrapper.find('span').element;
|
|
16
10
|
|
|
17
11
|
expect(element.textContent).toBe(label);
|
|
18
12
|
});
|
|
19
|
-
|
|
20
|
-
it('should display an icon', () => {
|
|
21
|
-
const icon = 'my-icon';
|
|
22
|
-
const wrapper = mount(Banner, { propsData: { icon } });
|
|
23
|
-
|
|
24
|
-
const element = wrapper.find(`.${ icon }`).element;
|
|
25
|
-
|
|
26
|
-
expect(element.classList).toContain(icon);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should not display an icon', () => {
|
|
30
|
-
const wrapper = mount(Banner);
|
|
31
|
-
|
|
32
|
-
const element = wrapper.find(`[data-testid="banner-icon"]`).element;
|
|
33
|
-
|
|
34
|
-
expect(element).not.toBeDefined();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should emit close event', () => {
|
|
38
|
-
const wrapper = mount(Banner, { propsData: { closable: true } });
|
|
39
|
-
const element = wrapper.find(`[data-testid="banner-close"]`).element;
|
|
40
|
-
|
|
41
|
-
element.click();
|
|
42
|
-
|
|
43
|
-
expect(wrapper.emitted('close')).toHaveLength(1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should add the right color', () => {
|
|
47
|
-
const color = 'red';
|
|
48
|
-
const wrapper = mount(Banner, { propsData: { color } });
|
|
49
|
-
|
|
50
|
-
const element = wrapper.element;
|
|
51
|
-
|
|
52
|
-
expect(element.classList).toContain(color);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should stack the banner messages', () => {
|
|
56
|
-
const stacked = true;
|
|
57
|
-
const wrapper = mount(Banner, { propsData: { stacked } });
|
|
58
|
-
|
|
59
|
-
const element = wrapper.find(`[data-testid="banner-content"]`).element;
|
|
60
|
-
|
|
61
|
-
expect(element.classList).toContain('stacked');
|
|
62
|
-
});
|
|
63
13
|
});
|
|
@@ -27,13 +27,6 @@ export default Vue.extend({
|
|
|
27
27
|
type: String,
|
|
28
28
|
default: null
|
|
29
29
|
},
|
|
30
|
-
/**
|
|
31
|
-
* Add icon for the banner
|
|
32
|
-
*/
|
|
33
|
-
icon: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: null
|
|
36
|
-
},
|
|
37
30
|
/**
|
|
38
31
|
* Toggles the banner's close button.
|
|
39
32
|
*/
|
|
@@ -65,137 +58,31 @@ export default Vue.extend({
|
|
|
65
58
|
class="banner"
|
|
66
59
|
:class="{
|
|
67
60
|
[color]: true,
|
|
61
|
+
closable,
|
|
62
|
+
stacked
|
|
68
63
|
}"
|
|
69
64
|
>
|
|
70
|
-
<
|
|
71
|
-
v-if="
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:class="icon"
|
|
78
|
-
/>
|
|
79
|
-
</div>
|
|
80
|
-
<div
|
|
81
|
-
class="banner__content"
|
|
82
|
-
data-testid="banner-content"
|
|
83
|
-
:class="{
|
|
84
|
-
closable,
|
|
85
|
-
stacked,
|
|
86
|
-
icon
|
|
87
|
-
}"
|
|
88
|
-
>
|
|
89
|
-
<slot>
|
|
90
|
-
<t
|
|
91
|
-
v-if="labelKey"
|
|
92
|
-
:k="labelKey"
|
|
93
|
-
:raw="true"
|
|
94
|
-
/>
|
|
95
|
-
<span v-else-if="messageLabel">{{ messageLabel }}</span>
|
|
96
|
-
<span
|
|
97
|
-
v-else
|
|
98
|
-
v-clean-html="nlToBr(label)"
|
|
99
|
-
/>
|
|
100
|
-
</slot>
|
|
101
|
-
<div
|
|
102
|
-
v-if="closable"
|
|
103
|
-
class="banner__content__closer"
|
|
104
|
-
@click="$emit('close')"
|
|
105
|
-
>
|
|
106
|
-
<i
|
|
107
|
-
data-testid="banner-close"
|
|
108
|
-
class="icon icon-close closer-icon"
|
|
109
|
-
/>
|
|
110
|
-
</div>
|
|
65
|
+
<slot>
|
|
66
|
+
<t v-if="labelKey" :k="labelKey" :raw="true" />
|
|
67
|
+
<span v-else-if="messageLabel">{{ messageLabel }}</span>
|
|
68
|
+
<span v-else v-html="nlToBr(label)" />
|
|
69
|
+
</slot>
|
|
70
|
+
<div v-if="closable" class="closer" @click="$emit('close')">
|
|
71
|
+
<i class="icon icon-2x icon-close closer-icon" />
|
|
111
72
|
</div>
|
|
112
73
|
</div>
|
|
113
74
|
</template>
|
|
114
75
|
|
|
115
76
|
<style lang="scss" scoped>
|
|
116
|
-
$left-border-size: 4px;
|
|
117
|
-
$icon-size: 24px;
|
|
118
|
-
|
|
119
|
-
.banner {
|
|
120
|
-
display: flex;
|
|
121
|
-
margin: 15px 0;
|
|
122
|
-
position: relative;
|
|
123
|
-
width: 100%;
|
|
124
|
-
color: var(--body-text);
|
|
125
|
-
|
|
126
|
-
&__icon {
|
|
127
|
-
width: $icon-size * 2;
|
|
128
|
-
flex-grow: 1;
|
|
129
|
-
display: flex;
|
|
130
|
-
justify-content: center;
|
|
131
|
-
align-items: center;
|
|
132
|
-
box-sizing: content-box;
|
|
133
|
-
|
|
134
|
-
.primary & {
|
|
135
|
-
background: var(--primary);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.secondary & {
|
|
139
|
-
background: var(--default);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.success & {
|
|
143
|
-
background: var(--success);
|
|
144
|
-
}
|
|
77
|
+
$left-border-size: 4px;
|
|
145
78
|
|
|
146
|
-
|
|
147
|
-
background: var(--info);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.warning & {
|
|
151
|
-
background: var(--warning);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.error & {
|
|
155
|
-
background: var(--error);
|
|
156
|
-
color: var(--primary-text);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
&__content {
|
|
79
|
+
.banner {
|
|
161
80
|
padding: 10px;
|
|
81
|
+
margin: 15px 0;
|
|
82
|
+
width: 100%;
|
|
162
83
|
transition: all 0.2s ease;
|
|
84
|
+
position: relative;
|
|
163
85
|
line-height: 20px;
|
|
164
|
-
width: 100%;
|
|
165
|
-
border-left: solid $left-border-size transparent;
|
|
166
|
-
display: flex;
|
|
167
|
-
gap: 3px;
|
|
168
|
-
|
|
169
|
-
.primary & {
|
|
170
|
-
background: var(--primary);
|
|
171
|
-
border-color: var(--primary);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.secondary & {
|
|
175
|
-
background: var(--default-banner-bg);
|
|
176
|
-
border-color: var(--default);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.success & {
|
|
180
|
-
background: var(--success-banner-bg);
|
|
181
|
-
border-color: var(--success);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.info & {
|
|
185
|
-
background: var(--info-banner-bg);
|
|
186
|
-
border-color: var(--info);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.warning & {
|
|
190
|
-
background: var(--warning-banner-bg);
|
|
191
|
-
border-color: var(--warning);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.error & {
|
|
195
|
-
background: var(--error-banner-bg);
|
|
196
|
-
border-color: var(--error);
|
|
197
|
-
color: var(--error);
|
|
198
|
-
}
|
|
199
86
|
|
|
200
87
|
&.stacked {
|
|
201
88
|
padding: 0 10px;
|
|
@@ -210,10 +97,10 @@ $icon-size: 24px;
|
|
|
210
97
|
}
|
|
211
98
|
|
|
212
99
|
&.closable {
|
|
213
|
-
padding-right:
|
|
100
|
+
padding-right: 40px;
|
|
214
101
|
}
|
|
215
102
|
|
|
216
|
-
|
|
103
|
+
.closer {
|
|
217
104
|
display: flex;
|
|
218
105
|
align-items: center;
|
|
219
106
|
|
|
@@ -222,11 +109,12 @@ $icon-size: 24px;
|
|
|
222
109
|
top: 0;
|
|
223
110
|
right: 0;
|
|
224
111
|
bottom: 0;
|
|
225
|
-
width:
|
|
226
|
-
line-height:
|
|
112
|
+
width: 40px;
|
|
113
|
+
line-height: 42px;
|
|
227
114
|
text-align: center;
|
|
228
115
|
|
|
229
116
|
.closer-icon {
|
|
117
|
+
font-size: 22px;
|
|
230
118
|
opacity: 0.7;
|
|
231
119
|
|
|
232
120
|
&:hover {
|
|
@@ -236,9 +124,40 @@ $icon-size: 24px;
|
|
|
236
124
|
}
|
|
237
125
|
}
|
|
238
126
|
|
|
239
|
-
&.
|
|
240
|
-
|
|
127
|
+
&.primary {
|
|
128
|
+
background: var(--primary);
|
|
129
|
+
border-left: solid $left-border-size var(--primary);
|
|
130
|
+
color: var(--body-text);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&.secondary {
|
|
134
|
+
background: var(--default-banner-bg);
|
|
135
|
+
border-left: solid $left-border-size var(--default);
|
|
136
|
+
color: var(--body-text);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&.success {
|
|
140
|
+
background: var(--success-banner-bg);
|
|
141
|
+
border-left: solid $left-border-size var(--success);
|
|
142
|
+
color: var(--body-text);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&.info {
|
|
146
|
+
background: var(--info-banner-bg);
|
|
147
|
+
border-left: solid $left-border-size var(--info);
|
|
148
|
+
color: var(--body-text);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&.warning {
|
|
152
|
+
background: var(--warning-banner-bg);
|
|
153
|
+
border-left: solid $left-border-size var(--warning);
|
|
154
|
+
color: var(--body-text);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&.error {
|
|
158
|
+
background: var(--error-banner-bg);
|
|
159
|
+
border-left: solid $left-border-size var(--error);
|
|
160
|
+
color: var(--error);
|
|
241
161
|
}
|
|
242
162
|
}
|
|
243
|
-
}
|
|
244
163
|
</style>
|
|
@@ -49,45 +49,28 @@ export default Vue.extend({
|
|
|
49
49
|
sticky: {
|
|
50
50
|
type: Boolean,
|
|
51
51
|
default: false,
|
|
52
|
-
},
|
|
52
|
+
},
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
</script>
|
|
56
56
|
|
|
57
57
|
<template>
|
|
58
|
-
<div
|
|
59
|
-
class="card-container"
|
|
60
|
-
:class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}"
|
|
61
|
-
data-testid="card"
|
|
62
|
-
>
|
|
58
|
+
<div class="card-container" :class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}">
|
|
63
59
|
<div class="card-wrap">
|
|
64
|
-
<div
|
|
65
|
-
class="card-title"
|
|
66
|
-
data-testid="card-title-slot"
|
|
67
|
-
>
|
|
60
|
+
<div class="card-title">
|
|
68
61
|
<slot name="title">
|
|
69
62
|
{{ title }}
|
|
70
63
|
</slot>
|
|
71
64
|
</div>
|
|
72
|
-
<hr
|
|
73
|
-
<div
|
|
74
|
-
class="card-body"
|
|
75
|
-
data-testid="card-body-slot"
|
|
76
|
-
>
|
|
65
|
+
<hr />
|
|
66
|
+
<div class="card-body">
|
|
77
67
|
<slot name="body">
|
|
78
68
|
{{ content }}
|
|
79
69
|
</slot>
|
|
80
70
|
</div>
|
|
81
|
-
<div
|
|
82
|
-
v-if="showActions"
|
|
83
|
-
class="card-actions"
|
|
84
|
-
data-testid="card-actions-slot"
|
|
85
|
-
>
|
|
71
|
+
<div v-if="showActions" class="card-actions">
|
|
86
72
|
<slot name="actions">
|
|
87
|
-
<button
|
|
88
|
-
class="btn role-primary"
|
|
89
|
-
@click="buttonAction"
|
|
90
|
-
>
|
|
73
|
+
<button class="btn role-primary" @click="buttonAction">
|
|
91
74
|
{{ buttonText }}
|
|
92
75
|
</button>
|
|
93
76
|
</slot>
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { shallowMount
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
2
|
import { Checkbox } from './index';
|
|
3
3
|
|
|
4
|
-
describe('
|
|
5
|
-
const event = {
|
|
6
|
-
target: { tagName: 'input', href: null },
|
|
7
|
-
stopPropagation: () => { },
|
|
8
|
-
preventDefault: () => { }
|
|
9
|
-
} as unknown as MouseEvent;
|
|
10
|
-
|
|
4
|
+
describe('Checkbox.vue', () => {
|
|
11
5
|
it('is unchecked by default', () => {
|
|
12
6
|
const wrapper = shallowMount(Checkbox);
|
|
13
7
|
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
@@ -22,7 +16,7 @@ describe('checkbox.vue', () => {
|
|
|
22
16
|
expect(cbInput.checked).toBe(true);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('updates from false to true when props change', async() => {
|
|
19
|
+
it('updates from false to true when props change', async () => {
|
|
26
20
|
const wrapper = shallowMount(Checkbox);
|
|
27
21
|
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
28
22
|
|
|
@@ -33,36 +27,51 @@ describe('checkbox.vue', () => {
|
|
|
33
27
|
expect(cbInput.checked).toBe(true);
|
|
34
28
|
});
|
|
35
29
|
|
|
36
|
-
it('emits an input event with a true value', async() => {
|
|
37
|
-
const wrapper
|
|
30
|
+
it('emits an input event with a true value', async () => {
|
|
31
|
+
const wrapper = shallowMount(Checkbox);
|
|
32
|
+
const event = {
|
|
33
|
+
target: { tagName: 'input', href: null },
|
|
34
|
+
stopPropagation: () => { },
|
|
35
|
+
preventDefault: () => { }
|
|
36
|
+
};
|
|
38
37
|
|
|
39
|
-
wrapper.vm.clicked(event);
|
|
38
|
+
(wrapper.vm as any).clicked(event);
|
|
40
39
|
await wrapper.vm.$nextTick();
|
|
41
40
|
|
|
42
41
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
43
42
|
expect(wrapper.emitted().input?.[0][0]).toBe(true);
|
|
44
43
|
});
|
|
45
44
|
|
|
46
|
-
it('emits an input event with a custom valueWhenTrue', async() => {
|
|
45
|
+
it('emits an input event with a custom valueWhenTrue', async () => {
|
|
47
46
|
const valueWhenTrue = 'BIG IF TRUE';
|
|
47
|
+
const event = {
|
|
48
|
+
target: { tagName: 'input', href: null },
|
|
49
|
+
stopPropagation: () => { },
|
|
50
|
+
preventDefault: () => { }
|
|
51
|
+
};
|
|
48
52
|
|
|
49
|
-
const wrapper
|
|
53
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
|
|
50
54
|
|
|
51
|
-
wrapper.vm.clicked(event);
|
|
55
|
+
(wrapper.vm as any).clicked(event);
|
|
52
56
|
await wrapper.vm.$nextTick();
|
|
53
57
|
|
|
54
58
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
55
59
|
expect(wrapper.emitted().input?.[0][0]).toBe(valueWhenTrue);
|
|
56
60
|
});
|
|
57
61
|
|
|
58
|
-
it('updates from valueWhenTrue to falsy', async() => {
|
|
62
|
+
it('updates from valueWhenTrue to falsy', async () => {
|
|
59
63
|
const valueWhenTrue = 'REAL HUGE IF FALSE';
|
|
64
|
+
const event = {
|
|
65
|
+
target: { tagName: 'input', href: null },
|
|
66
|
+
stopPropagation: () => { },
|
|
67
|
+
preventDefault: () => { }
|
|
68
|
+
};
|
|
60
69
|
|
|
61
|
-
const wrapper
|
|
70
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
|
|
62
71
|
|
|
63
|
-
wrapper.vm.clicked(event);
|
|
72
|
+
(wrapper.vm as any).clicked(event);
|
|
64
73
|
await wrapper.vm.$nextTick();
|
|
65
74
|
|
|
66
|
-
expect(wrapper.emitted().input?.[0][0]).
|
|
67
|
-
})
|
|
75
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(null);
|
|
76
|
+
})
|
|
68
77
|
});
|