@rancher/shell 0.1.4 → 0.1.21
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/assets/brand/suse/favicon.png +0 -0
- package/assets/images/generic-plugin.svg +1 -7
- package/assets/translations/en-us.yaml +81 -47
- package/components/CommunityLinks.vue +40 -49
- package/components/ExplorerProjectsNamespaces.vue +20 -3
- package/components/LazyImage.vue +21 -8
- package/components/PromptRemove.vue +2 -2
- package/components/ResourceList/Masthead.vue +21 -1
- package/components/ResourceList/ResourceLoadingIndicator.vue +0 -8
- package/components/ResourceList/index.vue +9 -23
- package/components/SortableTable/index.vue +13 -10
- package/components/Tabbed/index.vue +25 -7
- package/components/TypeDescription.vue +10 -1
- package/components/fleet/FleetClusters.vue +6 -0
- package/components/fleet/FleetRepos.vue +7 -1
- package/components/form/Command.vue +5 -0
- package/components/form/EnvVars.vue +5 -0
- package/components/form/NameNsDescription.vue +3 -1
- package/components/form/NodeScheduling.vue +6 -1
- package/components/form/PodAffinity.vue +5 -0
- package/components/form/ServiceNameSelect.vue +5 -0
- package/components/form/ValueFromResource.vue +7 -1
- package/components/nav/TopLevelMenu.vue +2 -1
- package/config/home-links.js +155 -0
- package/config/private-label.js +1 -1
- package/config/product/manager.js +0 -2
- package/config/product/uiplugins.js +1 -1
- package/config/settings.js +3 -1
- package/config/uiplugins.js +63 -6
- package/config/version.js +17 -0
- package/core/plugin.ts +12 -0
- package/core/plugins.js +29 -5
- package/core/types.ts +6 -0
- package/creators/app/{.eslintignore → files/.eslintignore} +0 -0
- package/creators/app/{.eslintrc.js → files/.eslintrc.js} +0 -0
- package/creators/app/{.vscode → files/.vscode}/settings.json +0 -0
- package/creators/app/{babel.config.js → files/babel.config.js} +0 -0
- package/creators/app/{nuxt.config.js → files/nuxt.config.js} +0 -0
- package/creators/app/{tsconfig.json → files/tsconfig.json} +2 -1
- package/creators/app/init +16 -17
- package/creators/app/package.json +6 -0
- package/creators/pkg/{babel.config.js → files/babel.config.js} +0 -0
- package/creators/pkg/{index.ts → files/index.ts} +0 -0
- package/creators/pkg/{tsconfig.json → files/tsconfig.json} +13 -12
- package/creators/pkg/{vue.config.js → files/vue.config.js} +0 -0
- package/creators/pkg/init +1 -1
- package/creators/update/init +54 -0
- package/creators/update/package.json +20 -0
- package/creators/update/upgrade +56 -0
- package/creators/update/yarn-error.log +54 -0
- package/detail/workload/index.vue +1 -0
- package/edit/persistentvolume/index.vue +48 -13
- package/edit/persistentvolumeclaim.vue +31 -13
- package/edit/provisioning.cattle.io.cluster/rke2.vue +27 -19
- package/edit/workload/index.vue +19 -9
- package/edit/workload/mixins/workload.js +109 -114
- package/edit/workload/storage/index.vue +11 -17
- package/edit/workload/storage/persistentVolumeClaim/index.vue +5 -0
- package/edit/workload/storage/secret.vue +6 -1
- package/list/catalog.cattle.io.app.vue +10 -9
- package/list/catalog.cattle.io.clusterrepo.vue +6 -61
- package/list/cis.cattle.io.clusterscan.vue +12 -12
- package/list/fleet.cattle.io.bundle.vue +33 -28
- package/list/fleet.cattle.io.cluster.vue +26 -22
- package/list/fleet.cattle.io.clustergroup.vue +6 -0
- package/list/fleet.cattle.io.clusterregistrationtoken.vue +28 -24
- package/list/fleet.cattle.io.gitrepo.vue +25 -14
- package/list/helm.cattle.io.projecthelmchart.vue +52 -33
- package/list/logging.banzaicloud.io.clusterflow.vue +7 -12
- package/list/logging.banzaicloud.io.flow.vue +7 -14
- package/list/management.cattle.io.cluster.vue +26 -15
- package/list/management.cattle.io.feature.vue +13 -8
- package/list/management.cattle.io.user.vue +38 -19
- package/list/monitoring.coreos.com.alertmanagerconfig.vue +8 -15
- package/list/namespace.vue +14 -1
- package/list/node.vue +13 -16
- package/list/persistentvolume.vue +16 -9
- package/list/persistentvolumeclaim.vue +5 -8
- package/list/provisioning.cattle.io.cluster.vue +34 -8
- package/list/service.vue +24 -12
- package/list/ui.cattle.io.navlink.vue +6 -0
- package/list/workload.vue +2 -2
- package/middleware/authenticated.js +6 -0
- package/mixins/resource-fetch.js +12 -18
- package/mixins/resource-manager.js +126 -0
- package/models/catalog.cattle.io.uiplugin.js +4 -0
- package/models/pod.js +15 -5
- package/models/provisioning.cattle.io.cluster.js +4 -0
- package/models/workload.service.js +10 -0
- package/nuxt.config.js +2 -1
- package/package.json +1 -1
- package/pages/auth/login.vue +10 -0
- package/pages/auth/verify.vue +9 -0
- package/pages/c/_cluster/settings/DefaultLinksEditor.vue +108 -0
- package/pages/c/_cluster/settings/links.vue +53 -101
- package/pages/c/_cluster/settings/performance.vue +90 -7
- package/pages/c/_cluster/uiplugins/DeveloperInstallDialog.vue +3 -3
- package/pages/c/_cluster/uiplugins/InstallDialog.vue +71 -20
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +21 -5
- package/pages/c/_cluster/uiplugins/RemoveUIPlugins.vue +2 -7
- package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +23 -15
- package/pages/c/_cluster/uiplugins/UninstallDialog.vue +11 -4
- package/pages/c/_cluster/uiplugins/index.vue +179 -65
- package/pages/support/index.vue +31 -142
- package/plugins/dashboard-store/actions.js +19 -0
- package/plugins/dashboard-store/getters.js +20 -3
- package/plugins/dashboard-store/mutations.js +13 -7
- package/plugins/plugin.js +18 -15
- package/plugins/steve/getters.js +12 -0
- package/plugins/version.js +21 -0
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +6 -7
- package/rancher-components/components/BadgeState/BadgeState.spec.ts +12 -0
- package/rancher-components/components/BadgeState/BadgeState.vue +107 -0
- package/rancher-components/components/BadgeState/index.ts +1 -0
- package/rancher-components/components/Banner/Banner.test.ts +13 -0
- package/rancher-components/components/Banner/Banner.vue +163 -0
- package/rancher-components/components/Banner/index.ts +1 -0
- package/rancher-components/components/Card/Card.vue +150 -0
- package/rancher-components/components/Card/index.ts +1 -0
- package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +77 -0
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +395 -0
- package/rancher-components/components/Form/Checkbox/index.ts +1 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +29 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +343 -0
- package/rancher-components/components/Form/LabeledInput/index.ts +1 -0
- package/rancher-components/components/Form/Radio/RadioButton.vue +270 -0
- package/rancher-components/components/Form/Radio/RadioGroup.vue +235 -0
- package/rancher-components/components/Form/Radio/index.ts +2 -0
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +168 -0
- package/rancher-components/components/Form/TextArea/index.ts +1 -0
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +107 -0
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +137 -0
- package/rancher-components/components/Form/ToggleSwitch/index.ts +1 -0
- package/rancher-components/components/Form/index.ts +5 -0
- package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +137 -0
- package/rancher-components/components/LabeledTooltip/index.ts +1 -0
- package/scripts/publish-shell.sh +39 -6
- package/scripts/record-deps.js +37 -0
- package/scripts/test-plugins-build.sh +8 -5
- package/scripts/typegen.sh +84 -0
- package/store/auth.js +3 -0
- package/store/index.js +12 -3
- package/types/shell/index.d.ts +3046 -0
- package/utils/favicon.js +8 -2
- package/utils/gc/gc-interval.ts +40 -0
- package/utils/gc/gc-root-store.js +76 -0
- package/utils/gc/gc-route-changed.ts +44 -0
- package/utils/gc/gc-types.ts +21 -0
- package/utils/gc/gc.ts +282 -0
- package/config/footer.js +0 -18
- package/creators/pkg/nuxt.config.js +0 -6
- package/yarn-error.log +0 -195
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BadgeState } from './BadgeState.vue';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { Banner } from './index';
|
|
3
|
+
|
|
4
|
+
describe('component: Banner', () => {
|
|
5
|
+
it('should display text based on label', () => {
|
|
6
|
+
const label = 'test';
|
|
7
|
+
const wrapper = mount(Banner, { propsData: { label } });
|
|
8
|
+
|
|
9
|
+
const element = wrapper.find('span').element;
|
|
10
|
+
|
|
11
|
+
expect(element.textContent).toBe(label);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
import { nlToBr } from '@shell/utils/string';
|
|
4
|
+
import { stringify } from '@shell/utils/error';
|
|
5
|
+
|
|
6
|
+
export default Vue.extend({
|
|
7
|
+
props: {
|
|
8
|
+
/**
|
|
9
|
+
* A color class that represents the color of the banner.
|
|
10
|
+
* @values primary, secondary, success, warning, error, info
|
|
11
|
+
*/
|
|
12
|
+
color: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'secondary'
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* The label to display as the banner's default content.
|
|
18
|
+
*/
|
|
19
|
+
label: {
|
|
20
|
+
type: [String, Error, Object],
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* The i18n key for the label to display as the banner's default content.
|
|
25
|
+
*/
|
|
26
|
+
labelKey: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: null
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Toggles the banner's close button.
|
|
32
|
+
*/
|
|
33
|
+
closable: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Toggles the stacked class for the banner.
|
|
39
|
+
*/
|
|
40
|
+
stacked: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
computed: {
|
|
46
|
+
/**
|
|
47
|
+
* Return message text as label.
|
|
48
|
+
*/
|
|
49
|
+
messageLabel(): string | void {
|
|
50
|
+
return !(typeof this.label === 'string') ? stringify(this.label) : undefined;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
methods: { nlToBr }
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
<template>
|
|
57
|
+
<div
|
|
58
|
+
class="banner"
|
|
59
|
+
:class="{
|
|
60
|
+
[color]: true,
|
|
61
|
+
closable,
|
|
62
|
+
stacked
|
|
63
|
+
}"
|
|
64
|
+
>
|
|
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" />
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style lang="scss" scoped>
|
|
77
|
+
$left-border-size: 4px;
|
|
78
|
+
|
|
79
|
+
.banner {
|
|
80
|
+
padding: 10px;
|
|
81
|
+
margin: 15px 0;
|
|
82
|
+
width: 100%;
|
|
83
|
+
transition: all 0.2s ease;
|
|
84
|
+
position: relative;
|
|
85
|
+
line-height: 20px;
|
|
86
|
+
|
|
87
|
+
&.stacked {
|
|
88
|
+
padding: 0 10px;
|
|
89
|
+
margin: 0;
|
|
90
|
+
transition: none;
|
|
91
|
+
&:first-child {
|
|
92
|
+
padding-top: 10px;
|
|
93
|
+
}
|
|
94
|
+
&:last-child {
|
|
95
|
+
padding-bottom: 10px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&.closable {
|
|
100
|
+
padding-right: 40px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.closer {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 0;
|
|
110
|
+
right: 0;
|
|
111
|
+
bottom: 0;
|
|
112
|
+
width: 40px;
|
|
113
|
+
line-height: 42px;
|
|
114
|
+
text-align: center;
|
|
115
|
+
|
|
116
|
+
.closer-icon {
|
|
117
|
+
font-size: 22px;
|
|
118
|
+
opacity: 0.7;
|
|
119
|
+
|
|
120
|
+
&:hover {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
color: var(--link);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
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);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Banner } from './Banner.vue';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
|
|
4
|
+
export default Vue.extend({
|
|
5
|
+
name: 'Card',
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* The card's title.
|
|
9
|
+
*/
|
|
10
|
+
title: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ''
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* The text content for the card's body.
|
|
16
|
+
*/
|
|
17
|
+
content: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: ''
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* The function to invoke when the default action button is clicked.
|
|
23
|
+
*/
|
|
24
|
+
buttonAction: {
|
|
25
|
+
type: Function,
|
|
26
|
+
default: (): void => { }
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* The text for the default action button.
|
|
30
|
+
*/
|
|
31
|
+
buttonText: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'go'
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Toggles the card's highlight-border class.
|
|
37
|
+
*/
|
|
38
|
+
showHighlightBorder: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Toggles the card's Actions section.
|
|
44
|
+
*/
|
|
45
|
+
showActions: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true
|
|
48
|
+
},
|
|
49
|
+
sticky: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<div class="card-container" :class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}">
|
|
59
|
+
<div class="card-wrap">
|
|
60
|
+
<div class="card-title">
|
|
61
|
+
<slot name="title">
|
|
62
|
+
{{ title }}
|
|
63
|
+
</slot>
|
|
64
|
+
</div>
|
|
65
|
+
<hr />
|
|
66
|
+
<div class="card-body">
|
|
67
|
+
<slot name="body">
|
|
68
|
+
{{ content }}
|
|
69
|
+
</slot>
|
|
70
|
+
</div>
|
|
71
|
+
<div v-if="showActions" class="card-actions">
|
|
72
|
+
<slot name="actions">
|
|
73
|
+
<button class="btn role-primary" @click="buttonAction">
|
|
74
|
+
{{ buttonText }}
|
|
75
|
+
</button>
|
|
76
|
+
</slot>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<style lang='scss'>
|
|
83
|
+
.card-container {
|
|
84
|
+
&.highlight-border {
|
|
85
|
+
border-left: 5px solid var(--primary);
|
|
86
|
+
}
|
|
87
|
+
border-radius: var(--border-radius);
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-basis: 40%;
|
|
90
|
+
margin: 10px;
|
|
91
|
+
min-height: 100px;
|
|
92
|
+
padding: 10px;
|
|
93
|
+
box-shadow: 0 0 20px var(--shadow);
|
|
94
|
+
&:not(.top) {
|
|
95
|
+
align-items: top;
|
|
96
|
+
flex-direction: row;
|
|
97
|
+
justify-content: start;
|
|
98
|
+
}
|
|
99
|
+
.card-wrap {
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
& .card-body {
|
|
103
|
+
color: var(--input-label);
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
}
|
|
108
|
+
& .card-actions {
|
|
109
|
+
align-self: end;
|
|
110
|
+
display: flex;
|
|
111
|
+
padding-top: 20px;
|
|
112
|
+
}
|
|
113
|
+
& .card-title {
|
|
114
|
+
align-items: center;
|
|
115
|
+
display: flex;
|
|
116
|
+
width: 100%;
|
|
117
|
+
h5 {
|
|
118
|
+
margin: 0;
|
|
119
|
+
}
|
|
120
|
+
.flex-right {
|
|
121
|
+
margin-left: auto;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Sticky mode will stick header and footer to top and bottom with content in the middle scrolling
|
|
126
|
+
&.card-sticky {
|
|
127
|
+
// display: flex;
|
|
128
|
+
// flex-direction: column;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
|
|
131
|
+
.card-wrap {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
|
|
135
|
+
.card-body {
|
|
136
|
+
justify-content: flex-start;
|
|
137
|
+
overflow: scroll;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
> * {
|
|
141
|
+
flex: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.card-body {
|
|
145
|
+
flex: 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Card } from './Card.vue';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import { Checkbox } from './index';
|
|
3
|
+
|
|
4
|
+
describe('Checkbox.vue', () => {
|
|
5
|
+
it('is unchecked by default', () => {
|
|
6
|
+
const wrapper = shallowMount(Checkbox);
|
|
7
|
+
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
8
|
+
|
|
9
|
+
expect(cbInput.checked).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders a true value', () => {
|
|
13
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: true } });
|
|
14
|
+
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
15
|
+
|
|
16
|
+
expect(cbInput.checked).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('updates from false to true when props change', async () => {
|
|
20
|
+
const wrapper = shallowMount(Checkbox);
|
|
21
|
+
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
22
|
+
|
|
23
|
+
expect(cbInput.checked).toBe(false);
|
|
24
|
+
|
|
25
|
+
await wrapper.setProps({ value: true });
|
|
26
|
+
|
|
27
|
+
expect(cbInput.checked).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
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
|
+
};
|
|
37
|
+
|
|
38
|
+
(wrapper.vm as any).clicked(event);
|
|
39
|
+
await wrapper.vm.$nextTick();
|
|
40
|
+
|
|
41
|
+
expect(wrapper.emitted().input?.length).toBe(1);
|
|
42
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('emits an input event with a custom valueWhenTrue', async () => {
|
|
46
|
+
const valueWhenTrue = 'BIG IF TRUE';
|
|
47
|
+
const event = {
|
|
48
|
+
target: { tagName: 'input', href: null },
|
|
49
|
+
stopPropagation: () => { },
|
|
50
|
+
preventDefault: () => { }
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
|
|
54
|
+
|
|
55
|
+
(wrapper.vm as any).clicked(event);
|
|
56
|
+
await wrapper.vm.$nextTick();
|
|
57
|
+
|
|
58
|
+
expect(wrapper.emitted().input?.length).toBe(1);
|
|
59
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(valueWhenTrue);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('updates from valueWhenTrue to falsy', async () => {
|
|
63
|
+
const valueWhenTrue = 'REAL HUGE IF FALSE';
|
|
64
|
+
const event = {
|
|
65
|
+
target: { tagName: 'input', href: null },
|
|
66
|
+
stopPropagation: () => { },
|
|
67
|
+
preventDefault: () => { }
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
|
|
71
|
+
|
|
72
|
+
(wrapper.vm as any).clicked(event);
|
|
73
|
+
await wrapper.vm.$nextTick();
|
|
74
|
+
|
|
75
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(null);
|
|
76
|
+
})
|
|
77
|
+
});
|