From e14d3a6c7a1fde96b8431ccd05d52461e6257c5a Mon Sep 17 00:00:00 2001 From: rster20002 Date: Fri, 30 Jul 2021 11:04:33 +0200 Subject: [PATCH] Add initial tests --- .../_config.js | 5 +++++ .../child.svelte | 10 +++++++++ .../main.svelte | 9 ++++++++ .../_config.js | 5 +++++ .../child.svelte | 4 ++++ .../main.svelte | 9 ++++++++ .../_config.js | 5 +++++ .../main.svelte | 12 ++++++++++ .../_config.js | 5 +++++ .../main.svelte | 12 ++++++++++ .../_config.js | 11 ++++++++++ .../main.svelte | 18 +++++++++++++++ .../samples/error-handling-event/_config.js | 10 +++++++++ .../samples/error-handling-event/main.svelte | 16 ++++++++++++++ .../_config.js | 10 +++++++++ .../main.svelte | 22 +++++++++++++++++++ .../error-handling-template/_config.js | 5 +++++ .../error-handling-template/main.svelte | 12 ++++++++++ 18 files changed, 180 insertions(+) create mode 100644 test/runtime/samples/error-handling-bubble-to-parent-manually/_config.js create mode 100644 test/runtime/samples/error-handling-bubble-to-parent-manually/child.svelte create mode 100644 test/runtime/samples/error-handling-bubble-to-parent-manually/main.svelte create mode 100644 test/runtime/samples/error-handling-bubble-to-parent/_config.js create mode 100644 test/runtime/samples/error-handling-bubble-to-parent/child.svelte create mode 100644 test/runtime/samples/error-handling-bubble-to-parent/main.svelte create mode 100644 test/runtime/samples/error-handling-catch-after-error/_config.js create mode 100644 test/runtime/samples/error-handling-catch-after-error/main.svelte create mode 100644 test/runtime/samples/error-handling-catch-before-error/_config.js create mode 100644 test/runtime/samples/error-handling-catch-before-error/main.svelte create mode 100644 test/runtime/samples/error-handling-event-correct-this/_config.js create mode 100644 test/runtime/samples/error-handling-event-correct-this/main.svelte create mode 100644 test/runtime/samples/error-handling-event/_config.js create mode 100644 test/runtime/samples/error-handling-event/main.svelte create mode 100644 test/runtime/samples/error-handling-template-reactive/_config.js create mode 100644 test/runtime/samples/error-handling-template-reactive/main.svelte create mode 100644 test/runtime/samples/error-handling-template/_config.js create mode 100644 test/runtime/samples/error-handling-template/main.svelte diff --git a/test/runtime/samples/error-handling-bubble-to-parent-manually/_config.js b/test/runtime/samples/error-handling-bubble-to-parent-manually/_config.js new file mode 100644 index 0000000000..acd4e2a2f0 --- /dev/null +++ b/test/runtime/samples/error-handling-bubble-to-parent-manually/_config.js @@ -0,0 +1,5 @@ +export default { + test({ assert, component }) { + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-bubble-to-parent-manually/child.svelte b/test/runtime/samples/error-handling-bubble-to-parent-manually/child.svelte new file mode 100644 index 0000000000..36cedc81a4 --- /dev/null +++ b/test/runtime/samples/error-handling-bubble-to-parent-manually/child.svelte @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-bubble-to-parent-manually/main.svelte b/test/runtime/samples/error-handling-bubble-to-parent-manually/main.svelte new file mode 100644 index 0000000000..5c7caa7dc9 --- /dev/null +++ b/test/runtime/samples/error-handling-bubble-to-parent-manually/main.svelte @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-bubble-to-parent/_config.js b/test/runtime/samples/error-handling-bubble-to-parent/_config.js new file mode 100644 index 0000000000..acd4e2a2f0 --- /dev/null +++ b/test/runtime/samples/error-handling-bubble-to-parent/_config.js @@ -0,0 +1,5 @@ +export default { + test({ assert, component }) { + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-bubble-to-parent/child.svelte b/test/runtime/samples/error-handling-bubble-to-parent/child.svelte new file mode 100644 index 0000000000..19c327680a --- /dev/null +++ b/test/runtime/samples/error-handling-bubble-to-parent/child.svelte @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-bubble-to-parent/main.svelte b/test/runtime/samples/error-handling-bubble-to-parent/main.svelte new file mode 100644 index 0000000000..5c7caa7dc9 --- /dev/null +++ b/test/runtime/samples/error-handling-bubble-to-parent/main.svelte @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-catch-after-error/_config.js b/test/runtime/samples/error-handling-catch-after-error/_config.js new file mode 100644 index 0000000000..acd4e2a2f0 --- /dev/null +++ b/test/runtime/samples/error-handling-catch-after-error/_config.js @@ -0,0 +1,5 @@ +export default { + test({ assert, component }) { + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-catch-after-error/main.svelte b/test/runtime/samples/error-handling-catch-after-error/main.svelte new file mode 100644 index 0000000000..a5fdb5dfd8 --- /dev/null +++ b/test/runtime/samples/error-handling-catch-after-error/main.svelte @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-catch-before-error/_config.js b/test/runtime/samples/error-handling-catch-before-error/_config.js new file mode 100644 index 0000000000..acd4e2a2f0 --- /dev/null +++ b/test/runtime/samples/error-handling-catch-before-error/_config.js @@ -0,0 +1,5 @@ +export default { + test({ assert, component }) { + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-catch-before-error/main.svelte b/test/runtime/samples/error-handling-catch-before-error/main.svelte new file mode 100644 index 0000000000..f005604003 --- /dev/null +++ b/test/runtime/samples/error-handling-catch-before-error/main.svelte @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-event-correct-this/_config.js b/test/runtime/samples/error-handling-event-correct-this/_config.js new file mode 100644 index 0000000000..3f90d0b5cc --- /dev/null +++ b/test/runtime/samples/error-handling-event-correct-this/_config.js @@ -0,0 +1,11 @@ +export default { + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + const event = new window.MouseEvent('click'); + + await button.dispatchEvent(event); + + assert.equal(component.error, true); + assert.equal(component.that, button); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-event-correct-this/main.svelte b/test/runtime/samples/error-handling-event-correct-this/main.svelte new file mode 100644 index 0000000000..89fe5e86a4 --- /dev/null +++ b/test/runtime/samples/error-handling-event-correct-this/main.svelte @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-event/_config.js b/test/runtime/samples/error-handling-event/_config.js new file mode 100644 index 0000000000..edd0bd074b --- /dev/null +++ b/test/runtime/samples/error-handling-event/_config.js @@ -0,0 +1,10 @@ +export default { + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + const event = new window.MouseEvent('click'); + + await button.dispatchEvent(event); + + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-event/main.svelte b/test/runtime/samples/error-handling-event/main.svelte new file mode 100644 index 0000000000..18f89a2b2c --- /dev/null +++ b/test/runtime/samples/error-handling-event/main.svelte @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-template-reactive/_config.js b/test/runtime/samples/error-handling-template-reactive/_config.js new file mode 100644 index 0000000000..edd0bd074b --- /dev/null +++ b/test/runtime/samples/error-handling-template-reactive/_config.js @@ -0,0 +1,10 @@ +export default { + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + const event = new window.MouseEvent('click'); + + await button.dispatchEvent(event); + + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-template-reactive/main.svelte b/test/runtime/samples/error-handling-template-reactive/main.svelte new file mode 100644 index 0000000000..425d59046a --- /dev/null +++ b/test/runtime/samples/error-handling-template-reactive/main.svelte @@ -0,0 +1,22 @@ + + +{a.b.c} + + \ No newline at end of file diff --git a/test/runtime/samples/error-handling-template/_config.js b/test/runtime/samples/error-handling-template/_config.js new file mode 100644 index 0000000000..acd4e2a2f0 --- /dev/null +++ b/test/runtime/samples/error-handling-template/_config.js @@ -0,0 +1,5 @@ +export default { + test({ assert, component }) { + assert.equal(component.error, true); + } +} \ No newline at end of file diff --git a/test/runtime/samples/error-handling-template/main.svelte b/test/runtime/samples/error-handling-template/main.svelte new file mode 100644 index 0000000000..461211a87d --- /dev/null +++ b/test/runtime/samples/error-handling-template/main.svelte @@ -0,0 +1,12 @@ + + +{a.b.c} \ No newline at end of file