mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 19:41:42 +08:00
test(Dialog): enable function-call test cases (#12315)
This commit is contained in:
parent
0477c0e2e6
commit
bd7ee34eba
@ -0,0 +1,9 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`should allow to render JSX message 1`] = `
|
||||
<div class="van-dialog__message">
|
||||
<div>
|
||||
foo
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -6,20 +6,25 @@ import {
|
||||
resetDialogDefaultOptions,
|
||||
} from '../function-call';
|
||||
|
||||
test('should update default options when calling setDefaultOptions method', () => {
|
||||
test('should update default options when calling setDefaultOptions method', async () => {
|
||||
const wrapper = document.createElement('div');
|
||||
const text = 'hello world';
|
||||
|
||||
setDialogDefaultOptions({ message: 'foo', teleport: wrapper, });
|
||||
showDialog();
|
||||
setDialogDefaultOptions({ message: text });
|
||||
showDialog({ teleport: wrapper });
|
||||
await later();
|
||||
const dialog = wrapper.querySelector('.van-dialog');
|
||||
expect(dialog.innerHTML.includes('foo')).toBeTruthy();
|
||||
|
||||
assert(dialog);
|
||||
expect(dialog.innerHTML.includes(text)).toBeTruthy();
|
||||
|
||||
resetDialogDefaultOptions();
|
||||
showDialog({ teleport: wrapper });
|
||||
await later();
|
||||
const dialog2 = wrapper.querySelector('.van-dialog');
|
||||
expect(dialog2.innerHTML.includes('foo')).toBeFalsy();
|
||||
|
||||
assert(dialog2);
|
||||
expect(dialog2.innerHTML.includes(text)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('should render dialog after calling showDialog', async () => {
|
||||
@ -42,13 +47,14 @@ test('should close dialog after calling closeDialog', async () => {
|
||||
});
|
||||
|
||||
await later();
|
||||
const dialog = wrapper.querySelector('.van-dialog');
|
||||
const dialog = wrapper.querySelector('.van-dialog') as HTMLElement;
|
||||
|
||||
expect(dialog.style.display).toEqual('');
|
||||
|
||||
closeDialog();
|
||||
await later();
|
||||
expect(dialog.className.split(' ')).toContain(
|
||||
'van-dialog-bounce-leave-active'
|
||||
'van-dialog-bounce-leave-active',
|
||||
);
|
||||
});
|
||||
|
||||
@ -60,8 +66,8 @@ test('should allow to render JSX message', async () => {
|
||||
});
|
||||
|
||||
await later();
|
||||
const dialog = wrapper.querySelector('.van-dialog');
|
||||
const dialog = wrapper.querySelector('.van-dialog') as HTMLElement;
|
||||
expect(
|
||||
dialog.querySelector('.van-dialog__message').outerHTML
|
||||
dialog.querySelector('.van-dialog__message')?.outerHTML,
|
||||
).toMatchSnapshot();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user