-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cole
committed
Jun 14, 2024
1 parent
bdaf976
commit 1a53143
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
import Descriptions from '../index' | ||
import { Tooltip } from 'ant-design-vue' | ||
|
||
describe('Descriptions', () => { | ||
it('render', async () => { | ||
const wrapper = mount(Descriptions) | ||
expect(wrapper.exists()).toBeTruthy() | ||
}) | ||
|
||
it('props', async () => { | ||
const wrapper = mount(Descriptions, { | ||
props: { | ||
title: 'Test', | ||
params: { test: '123' }, | ||
request: (params) => { | ||
return Promise.resolve({ data: {} }) | ||
}, | ||
onLoad: (value) => { | ||
console.log(value) | ||
}, | ||
onRequestError: (error) => { | ||
console.log(error) | ||
} | ||
}, | ||
slots: { | ||
default: () => { | ||
return [ | ||
<Descriptions.Item label={'label'}/>, | ||
<Descriptions.Item label={'label'}> | ||
123 | ||
</Descriptions.Item>, | ||
<Descriptions.Item valueType={'text'} label={'label'}/> | ||
] | ||
}, | ||
extra: () => { | ||
return (<Tooltip>123</Tooltip>) | ||
} | ||
} | ||
}) | ||
expect(wrapper.exists()).toBeTruthy() | ||
}) | ||
|
||
it('props columns', async () => { | ||
const wrapper = mount(Descriptions, { | ||
props: { | ||
title: () => 'Test', | ||
params: { test: '123' }, | ||
columns: [ | ||
{ | ||
title: () => 'label', | ||
valueType: 'text', | ||
dataIndex: 'text', | ||
index: '1' | ||
} | ||
], | ||
request: (params) => { | ||
return Promise.reject('error') | ||
}, | ||
onLoad: (value) => { | ||
console.log(value) | ||
}, | ||
onRequestError: (error) => { | ||
console.log(error) | ||
} | ||
} | ||
}) | ||
expect(wrapper.exists()).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { config } from '@vue/test-utils' | ||
|
||
config.global.stubs = { | ||
transition: false, | ||
'transition-group': false, | ||
} | ||
|
||
global.window.resizeTo = (width, height) => { | ||
global.window.innerWidth = width || global.window.innerWidth | ||
global.window.innerHeight = height || global.window.innerHeight | ||
global.window.dispatchEvent(new Event('resize')) | ||
} | ||
|
||
global.window.scrollTo = () => {} | ||
|
||
global.window.matchMedia = (query) => { | ||
return { | ||
matches: false, | ||
addListener: () => {}, | ||
removeListener: () => {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters