feat(Dialog): allow to render JSX message (#8420)

* feat(Dialog): allow to render JSX message

* types: add DialogMessage type
This commit is contained in:
neverland
2021-03-29 15:51:02 +08:00
committed by GitHub
parent 1a6930fa73
commit eec186ac19
6 changed files with 60 additions and 21 deletions
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should allow to render JSX message 1`] = `
<div class="van-dialog__message">
<div>
foo
</div>
</div>
`;
+14
View File
@@ -49,3 +49,17 @@ test('should close dialog after calling Dialog.call', async () => {
'van-dialog-bounce-leave-active'
);
});
test('should allow to render JSX message', async () => {
const wrapper = document.createElement('div');
Dialog.alert({
message: () => <div>foo</div>,
teleport: wrapper,
});
await later();
const dialog = wrapper.querySelector('.van-dialog');
expect(
dialog.querySelector('.van-dialog__message').outerHTML
).toMatchSnapshot();
});