vue2-client 1.7.16 → 1.7.18

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.
@@ -0,0 +1,46 @@
1
+ import { createLocalVue, mount } from '@vue/test-utils'
2
+ import MyConfirm from '@vue2-client/base-client/components/common/XBadge'
3
+ import Plugins from '@vue2-client/base-client/plugins'
4
+ import Antd from 'ant-design-vue'
5
+
6
+ const localVue = createLocalVue()
7
+
8
+ // 此处与index.js保持一致,保证antd的组件和appdata可以正常载入
9
+ localVue.use(Antd)
10
+ localVue.use(Plugins)
11
+
12
+ describe('MyConfirm', () => {
13
+ beforeAll(() => {
14
+ // mock localStorage的数据
15
+ const getItemSpy = jest.spyOn(window.localStorage.__proto__, 'getItem')
16
+ getItemSpy.mockImplementation((key) => {
17
+ if (key === process.env.VUE_APP_BADGE_KEY) {
18
+ return JSON.stringify({
19
+ badgeStyleMap: {
20
+ red: {
21
+ status: 'red',
22
+ text: '红色(Red)'
23
+ },
24
+ blue: {
25
+ status: 'blue',
26
+ text: '蓝色(Blue)'
27
+ }
28
+ }
29
+ })
30
+ }
31
+ })
32
+ })
33
+ // 测试用例:正确渲染组件
34
+ it('renders correctly', () => {
35
+ const wrapper = mount(MyConfirm, {
36
+ localVue: localVue,
37
+ // 组件必要的传参
38
+ propsData: {
39
+ badgeKey: 'badgeStyleMap',
40
+ value: 'red'
41
+ }
42
+ })
43
+ console.debug('返回的组件html:' + wrapper.html())
44
+ expect(wrapper.exists()).toBe(true)
45
+ })
46
+ })