From 3d6cd65d940c2c147964d3fd64e405dd5521b8c3 Mon Sep 17 00:00:00 2001 From: qinmu Date: Fri, 6 May 2022 14:27:41 +0800 Subject: [PATCH] feat: add test for destroying empty component --- .../empty-component-destroy/Empty.svelte | 8 ++++++++ .../samples/empty-component-destroy/_config.js | 17 +++++++++++++++++ .../samples/empty-component-destroy/main.svelte | 8 ++++++++ 3 files changed, 33 insertions(+) create mode 100644 test/runtime/samples/empty-component-destroy/Empty.svelte create mode 100644 test/runtime/samples/empty-component-destroy/_config.js create mode 100644 test/runtime/samples/empty-component-destroy/main.svelte diff --git a/test/runtime/samples/empty-component-destroy/Empty.svelte b/test/runtime/samples/empty-component-destroy/Empty.svelte new file mode 100644 index 0000000000..0c2a7a9c3b --- /dev/null +++ b/test/runtime/samples/empty-component-destroy/Empty.svelte @@ -0,0 +1,8 @@ + + diff --git a/test/runtime/samples/empty-component-destroy/_config.js b/test/runtime/samples/empty-component-destroy/_config.js new file mode 100644 index 0000000000..0334ab2e80 --- /dev/null +++ b/test/runtime/samples/empty-component-destroy/_config.js @@ -0,0 +1,17 @@ +export default { + html: ` + + `, + + async test({ assert, target, window }) { + const button = target.querySelector('button'); + const event = new window.MouseEvent('click'); + const messages = []; + console.log = msg => messages.push(msg); + await button.dispatchEvent(event); + assert.htmlEqual(target.innerHTML, ` + + `); + assert.deepEqual(messages, ['destroy']); + } +}; diff --git a/test/runtime/samples/empty-component-destroy/main.svelte b/test/runtime/samples/empty-component-destroy/main.svelte new file mode 100644 index 0000000000..0ee5ef4a04 --- /dev/null +++ b/test/runtime/samples/empty-component-destroy/main.svelte @@ -0,0 +1,8 @@ + + + + +