@infly/ui 1.0.17 → 1.0.19
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/README.md +43 -43
- package/package.json +53 -29
- package/scripts/install-comp.js +13 -0
- package/src/Base/InflyCheckBox/InflyCheckBox.test.js +154 -0
- package/src/Base/InflyCheckBox/InflyCheckBox.vue +227 -0
- package/src/Base/InflyCheckBox/index.js +6 -0
- package/src/Base/InflyDialog/InflyDialog.test.js +122 -0
- package/src/Base/InflyDialog/InflyDialog.vue +111 -0
- package/src/Base/InflyDialog/index.js +6 -0
- package/src/Base/InflyForm/InflyForm.test.js +239 -0
- package/src/Base/InflyForm/InflyForm.vue +974 -0
- package/src/Base/InflyForm/index.js +6 -0
- package/src/Base/InflyInput/InflyInput.test.js +105 -0
- package/src/Base/InflyInput/InflyInput.vue +167 -0
- package/src/Base/InflyInput/index.js +6 -0
- package/src/Base/InflyList/InflyList.test.js +229 -0
- package/src/Base/InflyList/InflyList.vue +925 -0
- package/src/Base/InflyList/index.js +6 -0
- package/src/Base/InflySelect/InflySelect.js +0 -0
- package/src/Business/BusinessSwitch/BusinessSwitch.test.js +96 -0
- package/src/Business/BusinessSwitch/BusinessSwitch.vue +115 -0
- package/src/Business/BusinessSwitch/index.js +6 -0
- package/src/Business/BusinessTag/BusinessTag.test.js +83 -0
- package/src/Business/BusinessTag/BusinessTag.vue +58 -0
- package/src/Business/BusinessTag/index.js +6 -0
- package/src/Business/InstitutionSelect/InstitutionSelect.test.js +158 -0
- package/src/Business/InstitutionSelect/InstitutionSelect.vue +770 -0
- package/src/Business/InstitutionSelect/index.js +6 -0
- package/src/index.js +30 -0
- package/styles/base.scss +755 -0
- package/styles/index.scss +202 -0
- package/styles/mixin.scss +19 -0
- package/styles/variables.scss +24 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InflyInput 组件测试
|
|
3
|
+
*
|
|
4
|
+
* 验证输入组件的 v-model、类型映射、前后置内容。
|
|
5
|
+
*/
|
|
6
|
+
const { describe, it, assert, mount } = require("../../../test/helper");
|
|
7
|
+
const InflyInput = require("./InflyInput.vue");
|
|
8
|
+
|
|
9
|
+
describe("InflyInput", () => {
|
|
10
|
+
describe("渲染", () => {
|
|
11
|
+
it("默认渲染 el-input", () => {
|
|
12
|
+
const wrapper = mount(InflyInput, {
|
|
13
|
+
propsData: { value: "" },
|
|
14
|
+
});
|
|
15
|
+
assert.ok(wrapper.find(".el-input").exists());
|
|
16
|
+
wrapper.destroy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("type=el-autocomplete 时渲染 el-autocomplete", () => {
|
|
20
|
+
const wrapper = mount(InflyInput, {
|
|
21
|
+
propsData: { value: "" },
|
|
22
|
+
attrs: { type: "el-autocomplete" },
|
|
23
|
+
});
|
|
24
|
+
// el-autocomplete 有特定的 class
|
|
25
|
+
assert.ok(wrapper.find(".el-autocomplete") || wrapper.exists());
|
|
26
|
+
wrapper.destroy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("渲染容器 class", () => {
|
|
30
|
+
const wrapper = mount(InflyInput, {
|
|
31
|
+
propsData: {
|
|
32
|
+
value: "",
|
|
33
|
+
containerClass: "my-container",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
assert.ok(wrapper.find(".my-container").exists());
|
|
37
|
+
wrapper.destroy();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("v-model / 双向绑定", () => {
|
|
42
|
+
it("接受初始 value", () => {
|
|
43
|
+
const wrapper = mount(InflyInput, {
|
|
44
|
+
propsData: { value: "初始值" },
|
|
45
|
+
});
|
|
46
|
+
assert.equal(wrapper.vm.$data.inputValue, "初始值");
|
|
47
|
+
wrapper.destroy();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("value 变化时同步内部状态", async () => {
|
|
51
|
+
const wrapper = mount(InflyInput, {
|
|
52
|
+
propsData: { value: "旧值" },
|
|
53
|
+
});
|
|
54
|
+
wrapper.setProps({ value: "新值" });
|
|
55
|
+
await wrapper.vm.$nextTick();
|
|
56
|
+
assert.equal(wrapper.vm.$data.inputValue, "新值");
|
|
57
|
+
wrapper.destroy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("内部输入触发 input 事件(Vue 2 v-model)", () => {
|
|
61
|
+
const wrapper = mount(InflyInput, {
|
|
62
|
+
propsData: { value: "" },
|
|
63
|
+
});
|
|
64
|
+
wrapper.vm.$data.inputValue = "用户输入";
|
|
65
|
+
wrapper.vm.$emit("input", "用户输入");
|
|
66
|
+
assert.ok(wrapper.emitted().input);
|
|
67
|
+
wrapper.destroy();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("Props", () => {
|
|
72
|
+
it("支持 prepend 前置内容", () => {
|
|
73
|
+
const wrapper = mount(InflyInput, {
|
|
74
|
+
propsData: {
|
|
75
|
+
value: "",
|
|
76
|
+
prepend: "https://",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
assert.ok(wrapper.exists());
|
|
80
|
+
wrapper.destroy();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("支持 append 后置内容", () => {
|
|
84
|
+
const wrapper = mount(InflyInput, {
|
|
85
|
+
propsData: {
|
|
86
|
+
value: "",
|
|
87
|
+
append: ".com",
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
assert.ok(wrapper.exists());
|
|
91
|
+
wrapper.destroy();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("支持 wrapClass", () => {
|
|
95
|
+
const wrapper = mount(InflyInput, {
|
|
96
|
+
propsData: {
|
|
97
|
+
value: "",
|
|
98
|
+
wrapClass: "custom-wrap",
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
assert.ok(wrapper.find(".custom-wrap").exists());
|
|
102
|
+
wrapper.destroy();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="comp-InflyInput" :class="containerClass">
|
|
3
|
+
<component
|
|
4
|
+
v-model="inputValue"
|
|
5
|
+
:is="typeMap"
|
|
6
|
+
:class="['infly-input__wrap', wrapClass]"
|
|
7
|
+
:size="$attrs.size || 'mini'"
|
|
8
|
+
:placeholder="$attrs.placeholder || `请输入${$attrs.label}`"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
@select="handleSelect"
|
|
11
|
+
>
|
|
12
|
+
<template v-if="prepend" slot="prepend">
|
|
13
|
+
<el-select
|
|
14
|
+
v-if="prepend.options"
|
|
15
|
+
v-model="prependSelectValue"
|
|
16
|
+
v-bind="prepend"
|
|
17
|
+
@change="prepend.change || (() => {})"
|
|
18
|
+
>
|
|
19
|
+
<el-option
|
|
20
|
+
v-for="option in prepend.options"
|
|
21
|
+
:key="option.value"
|
|
22
|
+
:label="option.label"
|
|
23
|
+
:value="option.value"
|
|
24
|
+
></el-option>
|
|
25
|
+
</el-select>
|
|
26
|
+
<div v-else>{{ prepend }}</div>
|
|
27
|
+
</template>
|
|
28
|
+
<append-renderer v-if="append && append.inside" slot="append" :append="append" />
|
|
29
|
+
</component>
|
|
30
|
+
<append-renderer v-if="append && !append.inside" :append="append" />
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import Uts from "@infly/libs/module/Uts.js";
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
name: "InflyInput",
|
|
39
|
+
inheritAttrs: false,
|
|
40
|
+
components: {
|
|
41
|
+
RenderFunction: {
|
|
42
|
+
functional: true,
|
|
43
|
+
props: {
|
|
44
|
+
renderFn: {
|
|
45
|
+
type: Function,
|
|
46
|
+
required: true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
render(h, ctx) {
|
|
50
|
+
return ctx.props.renderFn();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
AppendRenderer: {
|
|
54
|
+
functional: true,
|
|
55
|
+
props: {
|
|
56
|
+
append: {
|
|
57
|
+
type: [String, Object, Function],
|
|
58
|
+
required: true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
render(h, ctx) {
|
|
62
|
+
const { append } = ctx.props;
|
|
63
|
+
|
|
64
|
+
if (Uts.isFunction(append)) {
|
|
65
|
+
return append();
|
|
66
|
+
}
|
|
67
|
+
if (Uts.isFunction(append?.render)) {
|
|
68
|
+
return append.render();
|
|
69
|
+
}
|
|
70
|
+
return h('span', append);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
props: {
|
|
75
|
+
// 必需 Props
|
|
76
|
+
value: {
|
|
77
|
+
type: [String, Number],
|
|
78
|
+
default: ""
|
|
79
|
+
},
|
|
80
|
+
// Vue3 默认 v-model -> modelValue
|
|
81
|
+
modelValue: {
|
|
82
|
+
type: [String, Number],
|
|
83
|
+
default: ""
|
|
84
|
+
},
|
|
85
|
+
wrapClass: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: ""
|
|
88
|
+
},
|
|
89
|
+
containerClass: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: ""
|
|
92
|
+
},
|
|
93
|
+
prepend: {
|
|
94
|
+
type: [String, Object],
|
|
95
|
+
default: ""
|
|
96
|
+
},
|
|
97
|
+
append: {
|
|
98
|
+
type: [String, Object, Function],
|
|
99
|
+
default: ""
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
computed: {
|
|
103
|
+
typeMap() {
|
|
104
|
+
let compType = "el-input";
|
|
105
|
+
if (this.$attrs.type === "el-autocomplete") {
|
|
106
|
+
compType = "el-autocomplete";
|
|
107
|
+
}
|
|
108
|
+
if (this.$attrs.type === "infly-input-number") {
|
|
109
|
+
compType = "el-input-number";
|
|
110
|
+
}
|
|
111
|
+
return compType;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
watch: {
|
|
115
|
+
// 外部 value 改变时,同步到内部 inputValue
|
|
116
|
+
value(newVal) {
|
|
117
|
+
this.inputValue = newVal || "";
|
|
118
|
+
},
|
|
119
|
+
modelValue(newVal) {
|
|
120
|
+
this.inputValue = newVal || "";
|
|
121
|
+
},
|
|
122
|
+
// 内部输入改变时,往外 emit input 事件
|
|
123
|
+
inputValue(newVal) {
|
|
124
|
+
this.$emit("input", newVal); // Vue2 用法
|
|
125
|
+
this.$emit("update:modelValue", newVal); // Vue3 用法
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
data() {
|
|
129
|
+
return {
|
|
130
|
+
inputValue: this.value || this.modelValue || "",
|
|
131
|
+
prependSelectValue: (this.prepend && this.prepend.defaultValue) || ""
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
methods: {
|
|
135
|
+
handleSelect(item) {
|
|
136
|
+
const { value } = item || {};
|
|
137
|
+
this.inputValue = value;
|
|
138
|
+
},
|
|
139
|
+
handleNativeInput(e) {
|
|
140
|
+
// 如果配置了 numberOnly 属性,则限制只能输入数字和小数点
|
|
141
|
+
if (this.$attrs.numberOnly !== undefined) {
|
|
142
|
+
const input = e.target;
|
|
143
|
+
const oldValue = input.value;
|
|
144
|
+
// 只保留数字和小数点
|
|
145
|
+
let newValue = oldValue.replace(/[^\d.]/g, '');
|
|
146
|
+
// 确保只有一个小数点
|
|
147
|
+
const parts = newValue.split('.');
|
|
148
|
+
if (parts.length > 2) {
|
|
149
|
+
newValue = parts[0] + '.' + parts.slice(1).join('');
|
|
150
|
+
}
|
|
151
|
+
// 如果值被修改了,更新输入框
|
|
152
|
+
if (oldValue !== newValue) {
|
|
153
|
+
input.value = newValue;
|
|
154
|
+
this.inputValue = newValue;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<style lang="scss" scoped>
|
|
163
|
+
.comp-InflyInput {
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
}
|
|
167
|
+
</style>
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InflyList 组件测试
|
|
3
|
+
*
|
|
4
|
+
* 验证列表组件的 tab 切换、表单集成、数据请求、分页等核心行为。
|
|
5
|
+
* 使用 shallowMount 隔离 InflyForm 子组件依赖。
|
|
6
|
+
*/
|
|
7
|
+
const { describe, it, assert, shallowMount } = require("../../../test/helper");
|
|
8
|
+
const InflyList = require("./InflyList.vue");
|
|
9
|
+
|
|
10
|
+
describe("InflyList", () => {
|
|
11
|
+
describe("渲染", () => {
|
|
12
|
+
it("渲染容器 div", () => {
|
|
13
|
+
const wrapper = shallowMount(InflyList, {
|
|
14
|
+
propsData: {
|
|
15
|
+
formData: {},
|
|
16
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
assert.ok(wrapper.find(".comp-InflyList").exists());
|
|
20
|
+
wrapper.destroy();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("默认渲染 el-tabs 容器", () => {
|
|
24
|
+
const wrapper = shallowMount(InflyList, {
|
|
25
|
+
propsData: {
|
|
26
|
+
formData: {},
|
|
27
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
// shallowMount stub 了 el-tabs,通过 vm 属性检查
|
|
31
|
+
assert.ok(wrapper.exists());
|
|
32
|
+
wrapper.destroy();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe("Props", () => {
|
|
37
|
+
it("formData 绑定响应式数据", () => {
|
|
38
|
+
const formData = { page: 1, pagesize: 10, total: 0 };
|
|
39
|
+
const wrapper = shallowMount(InflyList, {
|
|
40
|
+
propsData: {
|
|
41
|
+
formData,
|
|
42
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
assert.equal(wrapper.props().formData.page, 1);
|
|
46
|
+
wrapper.destroy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("isInnerList 控制内嵌样式", () => {
|
|
50
|
+
const wrapper = shallowMount(InflyList, {
|
|
51
|
+
propsData: {
|
|
52
|
+
formData: {},
|
|
53
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
54
|
+
isInnerList: true,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
assert.equal(wrapper.props().isInnerList, true);
|
|
58
|
+
wrapper.destroy();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("hideDivider 隐藏分隔线", () => {
|
|
62
|
+
const wrapper = shallowMount(InflyList, {
|
|
63
|
+
propsData: {
|
|
64
|
+
formData: {},
|
|
65
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
66
|
+
hideDivider: true,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
assert.equal(wrapper.props().hideDivider, true);
|
|
70
|
+
wrapper.destroy();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("defaultInit=false 时不自动请求数据", () => {
|
|
74
|
+
const wrapper = shallowMount(InflyList, {
|
|
75
|
+
propsData: {
|
|
76
|
+
formData: {},
|
|
77
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
78
|
+
defaultInit: false,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
// 不启动请求,showTableLoading 保持 false
|
|
82
|
+
assert.equal(wrapper.vm.$data.showTableLoading, false);
|
|
83
|
+
wrapper.destroy();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("customRender 默认使用 getNestedValue", () => {
|
|
87
|
+
const wrapper = shallowMount(InflyList, {
|
|
88
|
+
propsData: {
|
|
89
|
+
formData: {},
|
|
90
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
assert.equal(typeof wrapper.props().customRender, "function");
|
|
94
|
+
wrapper.destroy();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("Tab 相关", () => {
|
|
99
|
+
it("tabList 定义多 tab", () => {
|
|
100
|
+
const tabList = [
|
|
101
|
+
{ name: "all", label: "全部" },
|
|
102
|
+
{ name: "active", label: "进行中" },
|
|
103
|
+
];
|
|
104
|
+
const wrapper = shallowMount(InflyList, {
|
|
105
|
+
propsData: {
|
|
106
|
+
formData: {},
|
|
107
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
108
|
+
tabList,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
assert.equal(wrapper.vm.visibleTabList.length, 2);
|
|
112
|
+
wrapper.destroy();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("defaultTabName 设置初始活动 tab", () => {
|
|
116
|
+
const tabList = [
|
|
117
|
+
{ name: "all", label: "全部" },
|
|
118
|
+
{ name: "active", label: "进行中" },
|
|
119
|
+
];
|
|
120
|
+
const wrapper = shallowMount(InflyList, {
|
|
121
|
+
propsData: {
|
|
122
|
+
formData: {},
|
|
123
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
124
|
+
tabList,
|
|
125
|
+
defaultTabName: "active",
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
assert.equal(wrapper.vm.$data.activityTab, "active");
|
|
129
|
+
wrapper.destroy();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("hideTab=true 隐藏 tab header", () => {
|
|
133
|
+
const wrapper = shallowMount(InflyList, {
|
|
134
|
+
propsData: {
|
|
135
|
+
formData: {},
|
|
136
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
137
|
+
hideTab: true,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
assert.equal(wrapper.props().hideTab, true);
|
|
141
|
+
wrapper.destroy();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe("分页", () => {
|
|
146
|
+
it("hideJumpPageButton 隐藏跳转按钮", () => {
|
|
147
|
+
const wrapper = shallowMount(InflyList, {
|
|
148
|
+
propsData: {
|
|
149
|
+
formData: { total: 100, page: 1, pagesize: 10 },
|
|
150
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
151
|
+
hideJumpPageButton: true,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
assert.equal(wrapper.props().hideJumpPageButton, true);
|
|
155
|
+
wrapper.destroy();
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe("列配置", () => {
|
|
160
|
+
it("columns 正确分组为 default/custom", () => {
|
|
161
|
+
const columns = [
|
|
162
|
+
{ type: "selection" },
|
|
163
|
+
{ type: "index" },
|
|
164
|
+
{ prop: "name", label: "姓名" },
|
|
165
|
+
{ prop: "age", label: "年龄" },
|
|
166
|
+
];
|
|
167
|
+
const wrapper = shallowMount(InflyList, {
|
|
168
|
+
propsData: { formData: {}, columns },
|
|
169
|
+
});
|
|
170
|
+
const groups = wrapper.vm.columnGroups;
|
|
171
|
+
assert.equal(groups.defaultColumns.length, 2);
|
|
172
|
+
assert.equal(groups.customColumns.length, 2);
|
|
173
|
+
wrapper.destroy();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("过滤 isHide=true 的列", () => {
|
|
177
|
+
const columns = [
|
|
178
|
+
{ prop: "name", label: "姓名" },
|
|
179
|
+
{ prop: "secret", label: "机密", isHide: true },
|
|
180
|
+
];
|
|
181
|
+
const wrapper = shallowMount(InflyList, {
|
|
182
|
+
propsData: { formData: {}, columns },
|
|
183
|
+
});
|
|
184
|
+
const groups = wrapper.vm.columnGroups;
|
|
185
|
+
// 被隐藏的列不在 customColumns 中
|
|
186
|
+
const visibleProps = groups.customColumns.map((c) => c.prop);
|
|
187
|
+
assert.ok(visibleProps.includes("name"));
|
|
188
|
+
assert.ok(!visibleProps.includes("secret"));
|
|
189
|
+
wrapper.destroy();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe("shouldShowByConfig", () => {
|
|
194
|
+
it("isShow 函数返回 false 时隐藏", () => {
|
|
195
|
+
const wrapper = shallowMount(InflyList, {
|
|
196
|
+
propsData: {
|
|
197
|
+
formData: {},
|
|
198
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
const config = { isShow: () => false };
|
|
202
|
+
assert.equal(wrapper.vm.shouldShowByConfig(config, {}), false);
|
|
203
|
+
wrapper.destroy();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("isHide 函数返回 true 时隐藏", () => {
|
|
207
|
+
const wrapper = shallowMount(InflyList, {
|
|
208
|
+
propsData: {
|
|
209
|
+
formData: {},
|
|
210
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
const config = { isHide: () => true };
|
|
214
|
+
assert.equal(wrapper.vm.shouldShowByConfig(config, {}), false);
|
|
215
|
+
wrapper.destroy();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("无 isShow/isHide 时默认显示", () => {
|
|
219
|
+
const wrapper = shallowMount(InflyList, {
|
|
220
|
+
propsData: {
|
|
221
|
+
formData: {},
|
|
222
|
+
columns: [{ prop: "name", label: "姓名" }],
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
assert.equal(wrapper.vm.shouldShowByConfig({}, {}), true);
|
|
226
|
+
wrapper.destroy();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
});
|