diff --git a/.eslintignore b/.eslintignore index b5cb03ae6e..d123c10530 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,7 +2,6 @@ **/expected.js _output test/*/samples/*/output.js -node_modules # automatically generated internal_exports.ts diff --git a/.eslintrc.js b/.eslintrc.js index 946a157e40..a093de610b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,65 +1,6 @@ module.exports = { root: true, - rules: { - indent: 'off', - 'no-unused-vars': 'off', - semi: [2, 'always'], - 'keyword-spacing': [2, { before: true, after: true }], - 'space-before-blocks': [2, 'always'], - 'no-mixed-spaces-and-tabs': [2, 'smart-tabs'], - 'no-cond-assign': 0, - 'object-shorthand': [2, 'always'], - 'no-const-assign': 2, - 'no-class-assign': 2, - 'no-this-before-super': 2, - 'no-var': 2, - 'no-unreachable': 2, - 'valid-typeof': 2, - 'quote-props': [2, 'as-needed'], - 'one-var': [2, 'never'], - 'prefer-arrow-callback': 2, - 'prefer-const': [2, { destructuring: 'all' }], - 'arrow-spacing': 2, - 'no-inner-declarations': 0, - 'require-atomic-updates': 'off', - '@typescript-eslint/indent': 'off', - '@typescript-eslint/camelcase': 'off', - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/array-type': ['error', 'array-simple'], - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/explicit-member-accessibility': 'off', - '@typescript-eslint/no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_' - } - ], - '@typescript-eslint/no-object-literal-type-assertion': 'off', - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/prefer-interface': 'off' - }, - globals: { - globalThis: false - }, - env: { - es6: true, - browser: true, - node: true, - mocha: true - }, - extends: [ - 'eslint:recommended', - 'plugin:import/errors', - 'plugin:import/warnings', - 'plugin:import/typescript', - 'plugin:@typescript-eslint/recommended' - ], - parserOptions: { - ecmaVersion: 9, - sourceType: 'module' - }, - plugins: ['svelte3'], + extends: '@sveltejs', settings: { 'import/core-modules': [ 'svelte', @@ -69,20 +10,5 @@ module.exports = { 'estree' ], 'svelte3/compiler': require('./compiler') - }, - overrides: [ - { - files: ['*.js'], - rules: { - '@typescript-eslint/no-var-requires': 'off' - } - }, - { - files: ['*.svelte'], - processor: 'svelte3/svelte3', - rules: { - '@typescript-eslint/indent': 'off' - } - } - ] + } }; diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 6871094f5c..7daff3f1ab 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -8,10 +8,13 @@ the issue. One way we prioritize issues is by the number of :+1: reactions on their descriptions. Please DO NOT add `+1` or :+1: comments. ### Feature requests and proposals + We're excited to hear how we can make Svelte better. Please add as much detail -as you can on your use case. +as you can on your use case. To propose an implementation of a large feature or +change, please create an [RFC](https://github.com/sveltejs/rfcs). ### Bugs + If you're filing an issue about a bug please include as much information as you can including the following. diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f5369e9991..2aa885cfcb 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,6 +7,8 @@ assignees: '' --- +## Is this about svelte@next? This project is currently in a pre-release stage and breaking changes may occur at any time. Please do not post any kind of bug reports or questions on GitHub about it. + **Describe the bug** A clear and concise description of what the bug is. @@ -35,6 +37,8 @@ If you have a stack trace to include, we recommend putting inside a `
`
**Information about your Svelte project:** +To make your life easier, just run `npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers` and paste the output here. + - Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10) - Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc) diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index e533c21c96..923bfdb50c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -7,6 +7,11 @@ assignees: '' --- + + **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. For example: I'm always frustrated when [...] diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1e77e0337a..d14a0f9fe4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,7 @@ - - ### Before submitting the PR, please make sure you do the following -- [ ] It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason. -- [ ] This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them. -- [ ] Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to `npm run lint`!) +- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs +- [ ] This message body should clearly illustrate what problems it solves. +- [ ] Ideally, include a test that fails without this PR but passes with it. + ### Tests -- [ ] Run the tests tests with `npm test` or `yarn test`) +- [ ] Run the tests with `npm test` and lint the project with `npm run lint` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14824ecdfa..4e04386fcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,12 +3,12 @@ on: [push, pull_request] jobs: Tests: runs-on: ${{ matrix.os }} + timeout-minutes: 10 strategy: matrix: - node-version: [8, 10, 12] + node-version: [8, 10, 12, 14] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - run: git config --global core.autocrlf false - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: @@ -19,12 +19,17 @@ jobs: CI: true Lint: runs-on: ubuntu-latest + timeout-minutes: 2 steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 - run: 'npm i && npm run lint' Unit: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 diff --git a/.gitignore b/.gitignore index 7a14244929..a471c3aaa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea .DS_Store .nyc_output +.vscode node_modules *.map /src/compiler/compile/internal_exports.ts @@ -17,10 +18,6 @@ node_modules /coverage/ /coverage.lcov /test/*/samples/_ -/test/sourcemaps/samples/*/output.js -/test/sourcemaps/samples/*/output.js.map -/test/sourcemaps/samples/*/output.css -/test/sourcemaps/samples/*/output.css.map /yarn-error.log _actual*.* _output diff --git a/.mocharc.js b/.mocharc.js new file mode 100644 index 0000000000..e55f26099e --- /dev/null +++ b/.mocharc.js @@ -0,0 +1,14 @@ +module.exports = { + file: [ + 'test/test.ts' + ], + require: [ + 'sucrase/register' + ] +}; + +// add coverage options when running 'npx c8 mocha' +if (process.env.NODE_V8_COVERAGE) { + module.exports.fullTrace = true; + module.exports.require.push('source-map-support/register'); +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 451fc58ca6..a9ff0e72de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,210 @@ # Svelte changelog -## Unreleased +## 3.29.7 +* Include `./register` in exports map ([#5670](https://github.com/sveltejs/svelte/issues/5670)) + +## 3.29.6 + +* Include `./package.json` in export map ([#5659](https://github.com/sveltejs/svelte/issues/5659)) + +## 3.29.5 + +* Fix `$$props` and `$$restProps` when compiling to a custom element ([#5482](https://github.com/sveltejs/svelte/issues/5482)) +* Include an export map in `package.json` ([#5556](https://github.com/sveltejs/svelte/issues/5556)) +* Fix function calls in `` props that use contextual values ([#5565](https://github.com/sveltejs/svelte/issues/5565)) +* Fix handling aborted transitions in `{:else}` blocks ([#5573](https://github.com/sveltejs/svelte/issues/5573)) +* Add `Element` and `Node` to known globals ([#5586](https://github.com/sveltejs/svelte/issues/5586)) +* Fix `$$slots` when compiling to custom elements ([#5594](https://github.com/sveltejs/svelte/issues/5594)) +* Fix internal `import`s so that we're exposing a valid ES module ([#5617](https://github.com/sveltejs/svelte/issues/5617)) + +## 3.29.4 + +* Fix code generation error with `??` alongside logical operators ([#5558](https://github.com/sveltejs/svelte/issues/5558)) + +## 3.29.3 + +* Hopefully actually republish with proper UMD build for use in the REPL + +## 3.29.2 + +* Republish with proper UMD build for use in the REPL + +## 3.29.1 + +* Fix compiler hanging on `` ([#5475](https://github.com/sveltejs/svelte/issues/5475)) +* Fix types on `get` function in `svelte/store` ([#5483](https://github.com/sveltejs/svelte/pull/5483)) +* Add missing `end` field on ASTs for non-top-level ` -

Todos

{#each todos as todo} -
+
{/each} diff --git a/site/content/examples/05-bindings/07-each-block-bindings/meta.json b/site/content/examples/05-bindings/08-each-block-bindings/meta.json similarity index 100% rename from site/content/examples/05-bindings/07-each-block-bindings/meta.json rename to site/content/examples/05-bindings/08-each-block-bindings/meta.json diff --git a/site/content/examples/05-bindings/08-media-elements/App.svelte b/site/content/examples/05-bindings/09-media-elements/App.svelte similarity index 93% rename from site/content/examples/05-bindings/08-media-elements/App.svelte rename to site/content/examples/05-bindings/09-media-elements/App.svelte index 469e9e12eb..45345a39ff 100644 --- a/site/content/examples/05-bindings/08-media-elements/App.svelte +++ b/site/content/examples/05-bindings/09-media-elements/App.svelte @@ -109,14 +109,15 @@
+ bind:paused> + +
diff --git a/site/content/examples/05-bindings/08-media-elements/meta.json b/site/content/examples/05-bindings/09-media-elements/meta.json similarity index 100% rename from site/content/examples/05-bindings/08-media-elements/meta.json rename to site/content/examples/05-bindings/09-media-elements/meta.json diff --git a/site/content/examples/05-bindings/09-dimensions/App.svelte b/site/content/examples/05-bindings/10-dimensions/App.svelte similarity index 100% rename from site/content/examples/05-bindings/09-dimensions/App.svelte rename to site/content/examples/05-bindings/10-dimensions/App.svelte diff --git a/site/content/examples/05-bindings/09-dimensions/meta.json b/site/content/examples/05-bindings/10-dimensions/meta.json similarity index 100% rename from site/content/examples/05-bindings/09-dimensions/meta.json rename to site/content/examples/05-bindings/10-dimensions/meta.json diff --git a/site/content/examples/05-bindings/10-bind-this/App.svelte b/site/content/examples/05-bindings/11-bind-this/App.svelte similarity index 99% rename from site/content/examples/05-bindings/10-bind-this/App.svelte rename to site/content/examples/05-bindings/11-bind-this/App.svelte index 8e4b3c5bef..439d240670 100644 --- a/site/content/examples/05-bindings/10-bind-this/App.svelte +++ b/site/content/examples/05-bindings/11-bind-this/App.svelte @@ -20,7 +20,7 @@ const t = window.performance.now(); const r = 64 + (128 * x / canvas.width) + (64 * Math.sin(t / 1000)); - const g = 64 + (128 * y / canvas.height) + (64 * Math.cos(t / 1000)); + const g = 64 + (128 * y / canvas.height) + (64 * Math.cos(t / 1400)); const b = 128; imageData.data[p + 0] = r; diff --git a/site/content/examples/05-bindings/10-bind-this/meta.json b/site/content/examples/05-bindings/11-bind-this/meta.json similarity index 100% rename from site/content/examples/05-bindings/10-bind-this/meta.json rename to site/content/examples/05-bindings/11-bind-this/meta.json diff --git a/site/content/examples/05-bindings/11-component-bindings/App.svelte b/site/content/examples/05-bindings/12-component-bindings/App.svelte similarity index 100% rename from site/content/examples/05-bindings/11-component-bindings/App.svelte rename to site/content/examples/05-bindings/12-component-bindings/App.svelte diff --git a/site/content/examples/05-bindings/11-component-bindings/Keypad.svelte b/site/content/examples/05-bindings/12-component-bindings/Keypad.svelte similarity index 100% rename from site/content/examples/05-bindings/11-component-bindings/Keypad.svelte rename to site/content/examples/05-bindings/12-component-bindings/Keypad.svelte diff --git a/site/content/examples/05-bindings/11-component-bindings/meta.json b/site/content/examples/05-bindings/12-component-bindings/meta.json similarity index 100% rename from site/content/examples/05-bindings/11-component-bindings/meta.json rename to site/content/examples/05-bindings/12-component-bindings/meta.json diff --git a/site/content/examples/06-lifecycle/02-update/App.svelte b/site/content/examples/06-lifecycle/02-update/App.svelte index 3eb2dceb52..419e763c57 100644 --- a/site/content/examples/06-lifecycle/02-update/App.svelte +++ b/site/content/examples/06-lifecycle/02-update/App.svelte @@ -20,7 +20,7 @@ ]; function handleKeydown(event) { - if (event.which === 13) { + if (event.key === 'Enter') { const text = event.target.value; if (!text) return; @@ -103,4 +103,4 @@
-
\ No newline at end of file +
diff --git a/site/content/examples/06-lifecycle/03-tick/App.svelte b/site/content/examples/06-lifecycle/03-tick/App.svelte index c9cb6de420..477b5ffb79 100644 --- a/site/content/examples/06-lifecycle/03-tick/App.svelte +++ b/site/content/examples/06-lifecycle/03-tick/App.svelte @@ -4,7 +4,7 @@ let text = `Select some text and hit the tab key to toggle uppercase`; async function handleKeydown(event) { - if (event.which !== 9) return; + if (event.key !== 'Tab') return; event.preventDefault(); @@ -34,4 +34,4 @@ } - \ No newline at end of file + diff --git a/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte b/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte index 3b3fb94d1c..396c793639 100644 --- a/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte +++ b/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte @@ -4,7 +4,7 @@ function typewriter(node, { speed = 50 }) { const valid = ( node.childNodes.length === 1 && - node.childNodes[0].nodeType === 3 + node.childNodes[0].nodeType === Node.TEXT_NODE ); if (!valid) { @@ -33,4 +33,4 @@

The quick brown fox jumps over the lazy dog

-{/if} \ No newline at end of file +{/if} diff --git a/site/content/examples/10-animations/00-animate/App.svelte b/site/content/examples/10-animations/00-animate/App.svelte index 279821491b..a90d0ecfb5 100644 --- a/site/content/examples/10-animations/00-animate/App.svelte +++ b/site/content/examples/10-animations/00-animate/App.svelte @@ -112,7 +112,7 @@
diff --git a/site/content/examples/15-composition/04-conditional-slots/App.svelte b/site/content/examples/15-composition/04-conditional-slots/App.svelte new file mode 100644 index 0000000000..69142b807d --- /dev/null +++ b/site/content/examples/15-composition/04-conditional-slots/App.svelte @@ -0,0 +1,13 @@ + + + + Bob + bob@email.com + + + + Alice + 12345678 + diff --git a/site/content/examples/15-composition/04-conditional-slots/Profile.svelte b/site/content/examples/15-composition/04-conditional-slots/Profile.svelte new file mode 100644 index 0000000000..09026cd6d6 --- /dev/null +++ b/site/content/examples/15-composition/04-conditional-slots/Profile.svelte @@ -0,0 +1,24 @@ + + +
+
Name
+ + {#if $$slots.email} +
Email
+ + {/if} + {#if $$slots.phone} +
Phone
+ + {/if} +
diff --git a/site/content/examples/15-composition/04-conditional-slots/meta.json b/site/content/examples/15-composition/04-conditional-slots/meta.json new file mode 100644 index 0000000000..95809f4c93 --- /dev/null +++ b/site/content/examples/15-composition/04-conditional-slots/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Conditional Slots" +} \ No newline at end of file diff --git a/site/content/examples/15-composition/04-modal/App.svelte b/site/content/examples/15-composition/05-modal/App.svelte similarity index 100% rename from site/content/examples/15-composition/04-modal/App.svelte rename to site/content/examples/15-composition/05-modal/App.svelte diff --git a/site/content/examples/15-composition/04-modal/Modal.svelte b/site/content/examples/15-composition/05-modal/Modal.svelte similarity index 100% rename from site/content/examples/15-composition/04-modal/Modal.svelte rename to site/content/examples/15-composition/05-modal/Modal.svelte diff --git a/site/content/examples/15-composition/04-modal/meta.json b/site/content/examples/15-composition/05-modal/meta.json similarity index 100% rename from site/content/examples/15-composition/04-modal/meta.json rename to site/content/examples/15-composition/05-modal/meta.json diff --git a/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte b/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte index e9cd617e96..608d04e497 100644 --- a/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte +++ b/site/content/examples/21-miscellaneous/01-hacker-news/Item.svelte @@ -3,6 +3,8 @@ export let item; export let returnTo; + + $: url = !item.domain ? `https://news.ycombinator.com/${item.url}` : item.url; - \ No newline at end of file + diff --git a/site/content/tutorial/07-lifecycle/04-tick/app-b/App.svelte b/site/content/tutorial/07-lifecycle/04-tick/app-b/App.svelte index c9cb6de420..477b5ffb79 100644 --- a/site/content/tutorial/07-lifecycle/04-tick/app-b/App.svelte +++ b/site/content/tutorial/07-lifecycle/04-tick/app-b/App.svelte @@ -4,7 +4,7 @@ let text = `Select some text and hit the tab key to toggle uppercase`; async function handleKeydown(event) { - if (event.which !== 9) return; + if (event.key !== 'Tab') return; event.preventDefault(); @@ -34,4 +34,4 @@ } - \ No newline at end of file + diff --git a/site/content/tutorial/07-lifecycle/04-tick/text.md b/site/content/tutorial/07-lifecycle/04-tick/text.md index b58b024ad6..8f5603a361 100644 --- a/site/content/tutorial/07-lifecycle/04-tick/text.md +++ b/site/content/tutorial/07-lifecycle/04-tick/text.md @@ -4,7 +4,7 @@ title: tick The `tick` function is unlike other lifecycle functions in that you can call it any time, not just when the component first initialises. It returns a promise that resolves as soon as any pending state changes have been applied to the DOM (or immediately, if there are no pending state changes). -When you invalidate component state in Svelte, it doesn't update the DOM immediately. Instead, it waits until the next *microtask* to see if there are any other changes that need to be applied, including in other components. Doing so avoids unnecessary work and allows the browser to batch things more effectively. +When you update component state in Svelte, it doesn't update the DOM immediately. Instead, it waits until the next *microtask* to see if there are any other changes that need to be applied, including in other components. Doing so avoids unnecessary work and allows the browser to batch things more effectively. You can see that behaviour in this example. Select a range of text and hit the tab key. Because the ``, + html: '', test({ assert, component, target }) { const textarea = target.querySelector('textarea'); assert.ok(textarea.readOnly === false); - }, + } }; diff --git a/test/runtime/samples/attribute-boolean-indeterminate/_config.js b/test/runtime/samples/attribute-boolean-indeterminate/_config.js index 0e24f92c51..d16cb5f96b 100644 --- a/test/runtime/samples/attribute-boolean-indeterminate/_config.js +++ b/test/runtime/samples/attribute-boolean-indeterminate/_config.js @@ -18,4 +18,4 @@ export default { component.indeterminate = false; assert.ok(!input.indeterminate); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/attribute-boolean-true/_config.js b/test/runtime/samples/attribute-boolean-true/_config.js index 0e402ed1e3..ccc0814296 100644 --- a/test/runtime/samples/attribute-boolean-true/_config.js +++ b/test/runtime/samples/attribute-boolean-true/_config.js @@ -1,7 +1,7 @@ export default { - html: ``, + html: '', test({ assert, component, target }) { const textarea = target.querySelector('textarea'); assert.ok(textarea.readOnly); - }, + } }; diff --git a/test/runtime/samples/attribute-boolean-with-spread/_config.js b/test/runtime/samples/attribute-boolean-with-spread/_config.js index 270804170d..1fd2443369 100644 --- a/test/runtime/samples/attribute-boolean-with-spread/_config.js +++ b/test/runtime/samples/attribute-boolean-with-spread/_config.js @@ -1,3 +1,3 @@ export default { - html: `` + html: '' }; diff --git a/test/runtime/samples/attribute-dataset-without-value/_config.js b/test/runtime/samples/attribute-dataset-without-value/_config.js index 934f44eb06..21e60b92aa 100644 --- a/test/runtime/samples/attribute-dataset-without-value/_config.js +++ b/test/runtime/samples/attribute-dataset-without-value/_config.js @@ -1,3 +1,3 @@ export default { - html: '
', + html: '
' }; diff --git a/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js b/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js index acf3c64bdd..f1088830af 100644 --- a/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js +++ b/test/runtime/samples/attribute-dynamic-no-dependencies/_config.js @@ -1,5 +1,5 @@ export default { html: `
bar
- `, + ` }; diff --git a/test/runtime/samples/attribute-dynamic-quotemarks/_config.js b/test/runtime/samples/attribute-dynamic-quotemarks/_config.js index b9f4364624..d74a0445d2 100644 --- a/test/runtime/samples/attribute-dynamic-quotemarks/_config.js +++ b/test/runtime/samples/attribute-dynamic-quotemarks/_config.js @@ -1,3 +1,3 @@ export default { - html: `foo` + html: 'foo' }; diff --git a/test/runtime/samples/attribute-dynamic-shorthand/_config.js b/test/runtime/samples/attribute-dynamic-shorthand/_config.js index 53f474db23..ebf4dd3881 100644 --- a/test/runtime/samples/attribute-dynamic-shorthand/_config.js +++ b/test/runtime/samples/attribute-dynamic-shorthand/_config.js @@ -1,8 +1,8 @@ export default { - html: `
`, + html: '
', test({ assert, component, target }) { component.id = 'bar'; - assert.equal( target.innerHTML, `
` ); + assert.equal( target.innerHTML, '
' ); } }; diff --git a/test/runtime/samples/attribute-dynamic-type/_config.js b/test/runtime/samples/attribute-dynamic-type/_config.js index 92f6ce196d..19aa33d65e 100644 --- a/test/runtime/samples/attribute-dynamic-type/_config.js +++ b/test/runtime/samples/attribute-dynamic-type/_config.js @@ -6,7 +6,7 @@ export default { inputValue: 42 }, - html: ``, + html: '', test({ assert, component, target }) { const input = target.querySelector('input'); diff --git a/test/runtime/samples/attribute-dynamic/_config.js b/test/runtime/samples/attribute-dynamic/_config.js index 04f419145d..34323a997e 100644 --- a/test/runtime/samples/attribute-dynamic/_config.js +++ b/test/runtime/samples/attribute-dynamic/_config.js @@ -1,5 +1,5 @@ export default { - html: `
red
`, + html: '
red
', test({ assert, component, target }) { const div = target.querySelector( 'div' ); @@ -7,7 +7,7 @@ export default { assert.equal( div.style.color, 'red' ); component.color = 'blue'; - assert.equal( target.innerHTML, `
blue
` ); + assert.equal( target.innerHTML, '
blue
' ); assert.equal( div.style.color, 'blue' ); } }; diff --git a/test/runtime/samples/attribute-empty/_config.js b/test/runtime/samples/attribute-empty/_config.js index b9ce14cce1..f9aaeb39a6 100644 --- a/test/runtime/samples/attribute-empty/_config.js +++ b/test/runtime/samples/attribute-empty/_config.js @@ -1,3 +1,3 @@ export default { - html: `
` + html: '
' }; diff --git a/test/runtime/samples/attribute-false/_config.js b/test/runtime/samples/attribute-false/_config.js index 9fd08a2a48..c05d83cb3d 100644 --- a/test/runtime/samples/attribute-false/_config.js +++ b/test/runtime/samples/attribute-false/_config.js @@ -1,3 +1,3 @@ export default { - html: `
`, + html: '
' }; diff --git a/test/runtime/samples/attribute-namespaced/_config.js b/test/runtime/samples/attribute-namespaced/_config.js index f8c0cb03fb..275a198219 100644 --- a/test/runtime/samples/attribute-namespaced/_config.js +++ b/test/runtime/samples/attribute-namespaced/_config.js @@ -11,4 +11,4 @@ export default { const use = target.querySelector( 'use' ); assert.equal( use.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ), '#bar' ); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/attribute-null-classname-no-style/_config.js b/test/runtime/samples/attribute-null-classname-no-style/_config.js index 4a78b680ef..6cfefc8834 100644 --- a/test/runtime/samples/attribute-null-classname-no-style/_config.js +++ b/test/runtime/samples/attribute-null-classname-no-style/_config.js @@ -1,9 +1,9 @@ export default { props: { - testName: "testClassName" + testName: 'testClassName' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); diff --git a/test/runtime/samples/attribute-null-classname-with-style/_config.js b/test/runtime/samples/attribute-null-classname-with-style/_config.js index 3ebc593b5d..d81543295e 100644 --- a/test/runtime/samples/attribute-null-classname-with-style/_config.js +++ b/test/runtime/samples/attribute-null-classname-with-style/_config.js @@ -1,5 +1,5 @@ export default { - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); diff --git a/test/runtime/samples/attribute-null-classnames-no-style/_config.js b/test/runtime/samples/attribute-null-classnames-no-style/_config.js index 917cf565c0..7281f5b637 100644 --- a/test/runtime/samples/attribute-null-classnames-no-style/_config.js +++ b/test/runtime/samples/attribute-null-classnames-no-style/_config.js @@ -1,10 +1,10 @@ export default { props: { - testName1: "test1", - testName2: "test2", + testName1: 'test1', + testName2: 'test2' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); @@ -15,11 +15,11 @@ export default { assert.equal(div.className, '0'); component.testName1 = null; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'nulltest'); component.testName1 = undefined; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'undefinedtest'); component.testName1 = undefined; diff --git a/test/runtime/samples/attribute-null-classnames-with-style/_config.js b/test/runtime/samples/attribute-null-classnames-with-style/_config.js index 5762f628fb..547e62427f 100644 --- a/test/runtime/samples/attribute-null-classnames-with-style/_config.js +++ b/test/runtime/samples/attribute-null-classnames-with-style/_config.js @@ -1,10 +1,10 @@ export default { props: { - testName1: "test1", - testName2: "test2", + testName1: 'test1', + testName2: 'test2' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); @@ -15,11 +15,11 @@ export default { assert.equal(div.className, '0 svelte-x1o6ra'); component.testName1 = null; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'nulltest svelte-x1o6ra'); component.testName1 = undefined; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'undefinedtest svelte-x1o6ra'); component.testName1 = undefined; diff --git a/test/runtime/samples/attribute-null-func-classname-no-style/_config.js b/test/runtime/samples/attribute-null-func-classname-no-style/_config.js index 4a78b680ef..6cfefc8834 100644 --- a/test/runtime/samples/attribute-null-func-classname-no-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classname-no-style/_config.js @@ -1,9 +1,9 @@ export default { props: { - testName: "testClassName" + testName: 'testClassName' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); diff --git a/test/runtime/samples/attribute-null-func-classname-with-style/_config.js b/test/runtime/samples/attribute-null-func-classname-with-style/_config.js index 1ed43d05b9..435a679da7 100644 --- a/test/runtime/samples/attribute-null-func-classname-with-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classname-with-style/_config.js @@ -1,9 +1,9 @@ export default { props: { - testName: "testClassName" + testName: 'testClassName' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); diff --git a/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js b/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js index 917cf565c0..7281f5b637 100644 --- a/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js @@ -1,10 +1,10 @@ export default { props: { - testName1: "test1", - testName2: "test2", + testName1: 'test1', + testName2: 'test2' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); @@ -15,11 +15,11 @@ export default { assert.equal(div.className, '0'); component.testName1 = null; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'nulltest'); component.testName1 = undefined; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'undefinedtest'); component.testName1 = undefined; diff --git a/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js b/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js index 5762f628fb..547e62427f 100644 --- a/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js @@ -1,10 +1,10 @@ export default { props: { - testName1: "test1", - testName2: "test2", + testName1: 'test1', + testName2: 'test2' }, - html: `
`, + html: '
', test({ assert, component, target }) { const div = target.querySelector('div'); @@ -15,11 +15,11 @@ export default { assert.equal(div.className, '0 svelte-x1o6ra'); component.testName1 = null; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'nulltest svelte-x1o6ra'); component.testName1 = undefined; - component.testName2 = "test"; + component.testName2 = 'test'; assert.equal(div.className, 'undefinedtest svelte-x1o6ra'); component.testName1 = undefined; diff --git a/test/runtime/samples/attribute-null/_config.js b/test/runtime/samples/attribute-null/_config.js index ae2f0a8af6..ded19eef79 100644 --- a/test/runtime/samples/attribute-null/_config.js +++ b/test/runtime/samples/attribute-null/_config.js @@ -1,3 +1,3 @@ export default { - html: `
`, + html: '
' }; diff --git a/test/runtime/samples/attribute-prefer-expression/_config.js b/test/runtime/samples/attribute-prefer-expression/_config.js index 29fcbc7f13..2388ff35df 100644 --- a/test/runtime/samples/attribute-prefer-expression/_config.js +++ b/test/runtime/samples/attribute-prefer-expression/_config.js @@ -2,7 +2,7 @@ export default { skip_if_ssr: true, props: { - foo: false, + foo: false }, test({ assert, component, target }) { @@ -15,5 +15,5 @@ export default { assert.ok(!inputs[0].checked); assert.ok(inputs[1].checked); - }, + } }; diff --git a/test/runtime/samples/attribute-static-at-symbol/_config.js b/test/runtime/samples/attribute-static-at-symbol/_config.js index 40a45579a3..0be19f091f 100644 --- a/test/runtime/samples/attribute-static-at-symbol/_config.js +++ b/test/runtime/samples/attribute-static-at-symbol/_config.js @@ -1,3 +1,3 @@ export default { - html: `email` -}; \ No newline at end of file + html: "email" +}; diff --git a/test/runtime/samples/attribute-static-boolean/_config.js b/test/runtime/samples/attribute-static-boolean/_config.js index c8b4332386..3dba036319 100644 --- a/test/runtime/samples/attribute-static-boolean/_config.js +++ b/test/runtime/samples/attribute-static-boolean/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', test({ assert, component, target }) { const textarea = target.querySelector( 'textarea' ); assert.ok( textarea.readOnly ); diff --git a/test/runtime/samples/attribute-static-quotemarks/_config.js b/test/runtime/samples/attribute-static-quotemarks/_config.js index 3d389c2273..e908052b4f 100644 --- a/test/runtime/samples/attribute-static-quotemarks/_config.js +++ b/test/runtime/samples/attribute-static-quotemarks/_config.js @@ -5,4 +5,4 @@ export default { bar ` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/attribute-static/_config.js b/test/runtime/samples/attribute-static/_config.js index 5d3b9c81a8..60c3cb2fc0 100644 --- a/test/runtime/samples/attribute-static/_config.js +++ b/test/runtime/samples/attribute-static/_config.js @@ -1,3 +1,3 @@ export default { - html: `
` + html: '
' }; diff --git a/test/runtime/samples/attribute-undefined/_config.js b/test/runtime/samples/attribute-undefined/_config.js index ae2f0a8af6..ded19eef79 100644 --- a/test/runtime/samples/attribute-undefined/_config.js +++ b/test/runtime/samples/attribute-undefined/_config.js @@ -1,3 +1,3 @@ export default { - html: `
`, + html: '
' }; diff --git a/test/runtime/samples/attribute-unknown-without-value/_config.js b/test/runtime/samples/attribute-unknown-without-value/_config.js index 4f7cf1cbbf..9645e86ef4 100644 --- a/test/runtime/samples/attribute-unknown-without-value/_config.js +++ b/test/runtime/samples/attribute-unknown-without-value/_config.js @@ -1,3 +1,3 @@ export default { html: '
' -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-catch-shorthand/_config.js b/test/runtime/samples/await-catch-shorthand/_config.js new file mode 100644 index 0000000000..fc65773107 --- /dev/null +++ b/test/runtime/samples/await-catch-shorthand/_config.js @@ -0,0 +1,41 @@ +let fulfil; + +let thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + thePromise + }, + + html: '', + + test({ assert, component, target }) { + fulfil(42); + + return thePromise + .then(() => { + assert.htmlEqual(target.innerHTML, ''); + + let reject; + + thePromise = new Promise((f, r) => { + reject = r; + }); + + component.thePromise = thePromise; + + assert.htmlEqual(target.innerHTML, ''); + + reject(new Error('something broke')); + + return thePromise.catch(() => {}); + }) + .then(() => { + assert.htmlEqual(target.innerHTML, ` +

oh no! something broke

+ `); + }); + } +}; diff --git a/test/runtime/samples/await-catch-shorthand/main.svelte b/test/runtime/samples/await-catch-shorthand/main.svelte new file mode 100644 index 0000000000..844e7da08c --- /dev/null +++ b/test/runtime/samples/await-catch-shorthand/main.svelte @@ -0,0 +1,7 @@ + + +{#await thePromise catch theError} +

oh no! {theError.message}

+{/await} \ No newline at end of file diff --git a/test/runtime/samples/await-component-oncreate/_config.js b/test/runtime/samples/await-component-oncreate/_config.js index 3cb8fa0864..1de86c9f44 100644 --- a/test/runtime/samples/await-component-oncreate/_config.js +++ b/test/runtime/samples/await-component-oncreate/_config.js @@ -13,4 +13,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-conservative-update/_config.js b/test/runtime/samples/await-conservative-update/_config.js index 4e81ff8e37..20a9448ebd 100644 --- a/test/runtime/samples/await-conservative-update/_config.js +++ b/test/runtime/samples/await-conservative-update/_config.js @@ -13,4 +13,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-conservative-update/sleep.js b/test/runtime/samples/await-conservative-update/sleep.js index 994f85f38a..be592a4ea4 100644 --- a/test/runtime/samples/await-conservative-update/sleep.js +++ b/test/runtime/samples/await-conservative-update/sleep.js @@ -8,4 +8,4 @@ export const sleep = ms => new Promise(f => { if (stopped) return; f(); }, ms); -}); \ No newline at end of file +}); diff --git a/test/runtime/samples/await-containing-if/_config.js b/test/runtime/samples/await-containing-if/_config.js index cd83585cc1..a81b040a12 100644 --- a/test/runtime/samples/await-containing-if/_config.js +++ b/test/runtime/samples/await-containing-if/_config.js @@ -24,7 +24,7 @@ export default { `); component.show = false; - assert.htmlEqual(target.innerHTML, `
`); + assert.htmlEqual(target.innerHTML, '
'); component.show = true; assert.htmlEqual(target.innerHTML, ` @@ -32,4 +32,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-in-dynamic-component/_config.js b/test/runtime/samples/await-in-dynamic-component/_config.js index 797298c554..d92757b68b 100644 --- a/test/runtime/samples/await-in-dynamic-component/_config.js +++ b/test/runtime/samples/await-in-dynamic-component/_config.js @@ -2,4 +2,4 @@ export default { test({ component }) { component.flag = false; } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-in-each/_config.js b/test/runtime/samples/await-in-each/_config.js index 6c7da69ee3..a648bbe38a 100644 --- a/test/runtime/samples/await-in-each/_config.js +++ b/test/runtime/samples/await-in-each/_config.js @@ -28,4 +28,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-in-removed-if/_config.js b/test/runtime/samples/await-in-removed-if/_config.js index 2f96f08e24..18b2ac7b74 100644 --- a/test/runtime/samples/await-in-removed-if/_config.js +++ b/test/runtime/samples/await-in-removed-if/_config.js @@ -9,7 +9,7 @@ export default { promise }, - html: ``, + html: '', async test({ assert, component, target }) { component.condition = false; @@ -17,6 +17,6 @@ export default { fulfil(); await new Promise(f => setTimeout(f, 0)); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-set-simultaneous-reactive/_config.js b/test/runtime/samples/await-set-simultaneous-reactive/_config.js index a591bf424f..0b5c0b8c74 100644 --- a/test/runtime/samples/await-set-simultaneous-reactive/_config.js +++ b/test/runtime/samples/await-set-simultaneous-reactive/_config.js @@ -1,5 +1,5 @@ export default { - html: `

wait for it...

`, + html: '

wait for it...

', test({ assert, component, target }) { return component.promise @@ -10,4 +10,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-set-simultaneous/_config.js b/test/runtime/samples/await-set-simultaneous/_config.js index f9ed64e556..fb75a9f6f0 100644 --- a/test/runtime/samples/await-set-simultaneous/_config.js +++ b/test/runtime/samples/await-set-simultaneous/_config.js @@ -6,7 +6,7 @@ export default { component.promise = promise; - assert.htmlEqual(target.innerHTML, `

wait for it...

`); + assert.htmlEqual(target.innerHTML, '

wait for it...

'); return promise .then(() => { @@ -15,4 +15,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-catch-event/_config.js b/test/runtime/samples/await-then-catch-event/_config.js index e42d16c4d8..0f4ce27628 100644 --- a/test/runtime/samples/await-then-catch-event/_config.js +++ b/test/runtime/samples/await-then-catch-event/_config.js @@ -42,4 +42,4 @@ export default { assert.equal(component.clicked, 43); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-catch-in-slot/_config.js b/test/runtime/samples/await-then-catch-in-slot/_config.js index b0600a0f27..14f3e7fdf5 100644 --- a/test/runtime/samples/await-then-catch-in-slot/_config.js +++ b/test/runtime/samples/await-then-catch-in-slot/_config.js @@ -44,4 +44,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-catch-multiple/_config.js b/test/runtime/samples/await-then-catch-multiple/_config.js index 2daac524a2..8d2de596df 100644 --- a/test/runtime/samples/await-then-catch-multiple/_config.js +++ b/test/runtime/samples/await-then-catch-multiple/_config.js @@ -48,4 +48,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-catch-no-values/_config.js b/test/runtime/samples/await-then-catch-no-values/_config.js index 2c3ce45dc1..51a79a50d0 100644 --- a/test/runtime/samples/await-then-catch-no-values/_config.js +++ b/test/runtime/samples/await-then-catch-no-values/_config.js @@ -9,14 +9,14 @@ export default { thePromise }, - html: `waiting`, + html: 'waiting', test({ assert, component, target }) { fulfil(9000); return thePromise .then(() => { - assert.htmlEqual(target.innerHTML, `resolved`); + assert.htmlEqual(target.innerHTML, 'resolved'); let reject; @@ -26,14 +26,14 @@ export default { component.thePromise = thePromise; - assert.htmlEqual(target.innerHTML, `waiting`); + assert.htmlEqual(target.innerHTML, 'waiting'); reject(new Error('something broke')); return thePromise.catch(() => {}); }) .then(() => { - assert.htmlEqual(target.innerHTML, `rejected`); + assert.htmlEqual(target.innerHTML, 'rejected'); }); } }; diff --git a/test/runtime/samples/await-then-catch-non-promise/_config.js b/test/runtime/samples/await-then-catch-non-promise/_config.js index dbc2f5eddc..c05236cc5f 100644 --- a/test/runtime/samples/await-then-catch-non-promise/_config.js +++ b/test/runtime/samples/await-then-catch-non-promise/_config.js @@ -14,4 +14,4 @@ export default {

the value is still not a promise

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-catch-static/_config.js b/test/runtime/samples/await-then-catch-static/_config.js index ada0dcc75b..35fc865d44 100644 --- a/test/runtime/samples/await-then-catch-static/_config.js +++ b/test/runtime/samples/await-then-catch-static/_config.js @@ -42,4 +42,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-catch/_config.js b/test/runtime/samples/await-then-catch/_config.js index b0600a0f27..14f3e7fdf5 100644 --- a/test/runtime/samples/await-then-catch/_config.js +++ b/test/runtime/samples/await-then-catch/_config.js @@ -44,4 +44,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-destruct-array/_config.js b/test/runtime/samples/await-then-destruct-array/_config.js new file mode 100644 index 0000000000..55c48481e0 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-array/_config.js @@ -0,0 +1,61 @@ +export default { + props: { + thePromise: new Promise(resolve => {}) + }, + + html: ` + loading... + `, + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve([1, 2])); + + assert.htmlEqual( + target.innerHTML, + ` +

a: 1

+

b: 2

+ ` + ); + + await (component.thePromise = Promise.resolve([4, 5])); + + assert.htmlEqual( + target.innerHTML, + ` +

a: 4

+

b: 5

+ ` + ); + + try { + await (component.thePromise = Promise.reject(['a', [6, 7]])); + } catch (e) { + // do nothing + } + + assert.htmlEqual( + target.innerHTML, + ` +

c: a

+

d: 6

+

e: 7

+ ` + ); + + try { + await (component.thePromise = Promise.reject(['b', [8, 9]])); + } catch (e) { + // do nothing + } + + assert.htmlEqual( + target.innerHTML, + ` +

c: b

+

d: 8

+

e: 9

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-array/main.svelte b/test/runtime/samples/await-then-destruct-array/main.svelte new file mode 100644 index 0000000000..cc0d217f79 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-array/main.svelte @@ -0,0 +1,14 @@ + + +{#await thePromise} + loading... +{:then [ a, b ]} +

a: {a}

+

b: {b}

+{:catch [c, [d, e]]} +

c: {c}

+

d: {d}

+

e: {e}

+{/await} \ No newline at end of file diff --git a/test/runtime/samples/await-then-destruct-default/_config.js b/test/runtime/samples/await-then-destruct-default/_config.js new file mode 100644 index 0000000000..d0e5a49f28 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-default/_config.js @@ -0,0 +1,23 @@ +export default { + async test({ assert, component, target }) { + await Promise.resolve(); + + assert.htmlEqual( + target.innerHTML, + ` +

a: 3

+

b: 2

+

c: 3

+

a: 1

+

b: 2

+

c: 3

+

a: 3

+

b: 2

+

c: 3

+

a: 1

+

b: 2

+

c: 3

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-default/main.svelte b/test/runtime/samples/await-then-destruct-default/main.svelte new file mode 100644 index 0000000000..d559aadab1 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-default/main.svelte @@ -0,0 +1,34 @@ + + +{#await object then { a = 3, b = 4, c }} +

a: {a}

+

b: {b}

+

c: {c}

+{/await} + +{#await array then [a, b, c = 3]} +

a: {a}

+

b: {b}

+

c: {c}

+{/await} + +{#await objectReject then value} + resolved +{:catch { a = 3, b = 4, c }} +

a: {a}

+

b: {b}

+

c: {c}

+{/await} + +{#await arrayReject then value} + resolved +{:catch [a, b, c = 3]} +

a: {a}

+

b: {b}

+

c: {c}

+{/await} \ No newline at end of file diff --git a/test/runtime/samples/await-then-destruct-object-if/_config.js b/test/runtime/samples/await-then-destruct-object-if/_config.js new file mode 100644 index 0000000000..6a29b2db37 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-object-if/_config.js @@ -0,0 +1,29 @@ +export default { + props: { + thePromise: Promise.resolve({ result: 1 }) + }, + + html: '', + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve({ result: 1 })); + + assert.htmlEqual( + target.innerHTML, + ` +

result: 1

+

count: 0

+ ` + ); + + await new Promise(resolve => setTimeout(resolve, 1)); + + assert.htmlEqual( + target.innerHTML, + ` +

result: 1

+

count: 1

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-object-if/main.svelte b/test/runtime/samples/await-then-destruct-object-if/main.svelte new file mode 100644 index 0000000000..3425979e2c --- /dev/null +++ b/test/runtime/samples/await-then-destruct-object-if/main.svelte @@ -0,0 +1,19 @@ + + +{#await thePromise then { result }} + {#if result} +

result: {result}

+

count: {count}

+ {:else} +

result: {result}

+

count: {count}

+ {/if} +{/await} diff --git a/test/runtime/samples/await-then-destruct-object/_config.js b/test/runtime/samples/await-then-destruct-object/_config.js new file mode 100644 index 0000000000..7d08ad3711 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-object/_config.js @@ -0,0 +1,63 @@ +export default { + props: { + thePromise: new Promise(resolve => {}) + }, + + html: ` + loading... + `, + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve({ error: 'error message' })); + + assert.htmlEqual( + target.innerHTML, + ` +

error: error message

+

result: undefined

+ ` + ); + + await (component.thePromise = Promise.resolve({ result: '42' })); + + assert.htmlEqual( + target.innerHTML, + ` +

error: undefined

+

result: 42

+ ` + ); + + try { + await (component.thePromise = Promise.reject({ + error: { message: 'oops', code: '123' } + })); + } catch (e) { + // do nothing + } + + assert.htmlEqual( + target.innerHTML, + ` +

message: oops

+

code: 123

+ ` + ); + + try { + await (component.thePromise = Promise.reject({ + error: { message: 'timeout', code: '456' } + })); + } catch (e) { + // do nothing + } + + assert.htmlEqual( + target.innerHTML, + ` +

message: timeout

+

code: 456

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-object/main.svelte b/test/runtime/samples/await-then-destruct-object/main.svelte new file mode 100644 index 0000000000..ff574b7be8 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-object/main.svelte @@ -0,0 +1,13 @@ + + +{#await thePromise} + loading... +{:then { result, error }} +

error: {error}

+

result: {result}

+{:catch { error: { message, code } }} +

message: {message}

+

code: {code}

+{/await} \ No newline at end of file diff --git a/test/runtime/samples/await-then-destruct-rest/_config.js b/test/runtime/samples/await-then-destruct-rest/_config.js new file mode 100644 index 0000000000..528568e569 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-rest/_config.js @@ -0,0 +1,21 @@ +export default { + async test({ assert, component, target }) { + await Promise.resolve(); + + assert.htmlEqual( + target.innerHTML, + ` +

a: 1

+

rest: {"b":2,"c":3}

+

a: 1

+

b: 2

+

rest: [3,4,5,6]

+

a: 1

+

rest: {"b":2,"c":3}

+

a: 1

+

b: 2

+

rest: [3,4,5,6]

+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-rest/main.svelte b/test/runtime/samples/await-then-destruct-rest/main.svelte new file mode 100644 index 0000000000..a2d57dabf3 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-rest/main.svelte @@ -0,0 +1,32 @@ + + +{#await object then { a, ...rest }} +

a: {a}

+

rest: {JSON.stringify(rest)}

+{/await} + +{#await array then [a, b, ...rest]} +

a: {a}

+

b: {b}

+

rest: {JSON.stringify(rest)}

+{/await} + +{#await objectReject then value} + resolved +{:catch { a, ...rest }} +

a: {a}

+

rest: {JSON.stringify(rest)}

+{/await} + +{#await arrayReject then value} + resolved +{:catch [a, b, ...rest]} +

a: {a}

+

b: {b}

+

rest: {JSON.stringify(rest)}

+{/await} \ No newline at end of file diff --git a/test/runtime/samples/await-then-if/_config.js b/test/runtime/samples/await-then-if/_config.js index b26688d9f3..f9e81dd2cc 100644 --- a/test/runtime/samples/await-then-if/_config.js +++ b/test/runtime/samples/await-then-if/_config.js @@ -22,4 +22,4 @@ export default {

promise array is empty

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-then-shorthand/_config.js b/test/runtime/samples/await-then-shorthand/_config.js index 4635cf5127..ca07dd19e0 100644 --- a/test/runtime/samples/await-then-shorthand/_config.js +++ b/test/runtime/samples/await-then-shorthand/_config.js @@ -9,7 +9,7 @@ export default { thePromise }, - html: ``, + html: '', test({ assert, component, target }) { fulfil(42); @@ -28,7 +28,7 @@ export default { component.thePromise = thePromise; - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); reject(new Error('something broke')); @@ -40,4 +40,4 @@ export default { `); }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/await-with-update-2/Component.svelte b/test/runtime/samples/await-with-update-2/Component.svelte new file mode 100644 index 0000000000..1301db3f99 --- /dev/null +++ b/test/runtime/samples/await-with-update-2/Component.svelte @@ -0,0 +1,7 @@ + + +
count: {count}
+
value: {value}
\ No newline at end of file diff --git a/test/runtime/samples/await-with-update-2/_config.js b/test/runtime/samples/await-with-update-2/_config.js new file mode 100644 index 0000000000..68f884c127 --- /dev/null +++ b/test/runtime/samples/await-with-update-2/_config.js @@ -0,0 +1,64 @@ +export default { + props: { + thePromise: new Promise((_) => {}), + count: 0 + }, + + html: ` +

loading...

+ `, + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve({ value: 'success', Component: component.Component })); + + assert.htmlEqual( + target.innerHTML, + ` +
Resolved: +
count: 0
+
value: success
+
+ ` + ); + + component.count = 5; + + assert.htmlEqual( + target.innerHTML, + ` +
Resolved: +
count: 5
+
value: success
+
+ ` + ); + + try { + await (component.thePromise = Promise.reject({ value: 'failure', Component: component.Component })); + } catch (error) { + // ignore + } + + assert.htmlEqual( + target.innerHTML, + ` +
Rejected: +
count: 5
+
value: failure
+
+ ` + ); + + component.count = 10; + + assert.htmlEqual( + target.innerHTML, + ` +
Rejected: +
count: 10
+
value: failure
+
+ ` + ); + } +}; diff --git a/test/runtime/samples/await-with-update-2/main.svelte b/test/runtime/samples/await-with-update-2/main.svelte new file mode 100644 index 0000000000..b29c875f92 --- /dev/null +++ b/test/runtime/samples/await-with-update-2/main.svelte @@ -0,0 +1,16 @@ + + +
+ {#await thePromise} +

loading...

+ {:then { value: theValue, Component }} + Resolved: + {:catch { value: theError, Component } } + Rejected: + {/await} +
\ No newline at end of file diff --git a/test/runtime/samples/await-with-update/Component.svelte b/test/runtime/samples/await-with-update/Component.svelte new file mode 100644 index 0000000000..5f13c80e65 --- /dev/null +++ b/test/runtime/samples/await-with-update/Component.svelte @@ -0,0 +1,5 @@ + + +
count: {count}
\ No newline at end of file diff --git a/test/runtime/samples/await-with-update/_config.js b/test/runtime/samples/await-with-update/_config.js new file mode 100644 index 0000000000..08bf12b89e --- /dev/null +++ b/test/runtime/samples/await-with-update/_config.js @@ -0,0 +1,60 @@ +export default { + props: { + thePromise: new Promise((_) => {}), + count: 0 + }, + + html: ` +

loading...

+ `, + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve(component.Component)); + + assert.htmlEqual( + target.innerHTML, + ` +
Resolved: +
count: 0
+
+ ` + ); + + component.count = 5; + + assert.htmlEqual( + target.innerHTML, + ` +
Resolved: +
count: 5
+
+ ` + ); + + try { + await (component.thePromise = Promise.reject(component.Component)); + } catch (error) { + // ignore + } + + assert.htmlEqual( + target.innerHTML, + ` +
Rejected: +
count: 5
+
+ ` + ); + + component.count = 10; + + assert.htmlEqual( + target.innerHTML, + ` +
Rejected: +
count: 10
+
+ ` + ); + } +}; diff --git a/test/runtime/samples/await-with-update/main.svelte b/test/runtime/samples/await-with-update/main.svelte new file mode 100644 index 0000000000..51c5b76a21 --- /dev/null +++ b/test/runtime/samples/await-with-update/main.svelte @@ -0,0 +1,16 @@ + + +
+ {#await thePromise} +

loading...

+ {:then theValue} + Resolved: + {:catch theError} + Rejected: + {/await} +
\ No newline at end of file diff --git a/test/runtime/samples/await-without-catch/_config.js b/test/runtime/samples/await-without-catch/_config.js new file mode 100644 index 0000000000..5bc291bf1f --- /dev/null +++ b/test/runtime/samples/await-without-catch/_config.js @@ -0,0 +1,45 @@ +let fulfil; + +let promise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + promise + }, + + html: ` +

loading...

+ `, + + test({ assert, component, target }) { + fulfil(42); + + return promise + .then(() => { + assert.htmlEqual(target.innerHTML, ` +

loaded

+ `); + + let reject; + + promise = new Promise((f, r) => { + reject = r; + }); + + component.promise = promise; + + assert.htmlEqual(target.innerHTML, ` +

loading...

+ `); + + reject(new Error('this error should be thrown')); + return promise; + }) + .catch((err) => { + assert.equal(err.message, 'this error should be thrown'); + assert.htmlEqual(target.innerHTML, ''); + }); + } +}; diff --git a/test/runtime/samples/await-without-catch/main.svelte b/test/runtime/samples/await-without-catch/main.svelte new file mode 100644 index 0000000000..f528a8bf69 --- /dev/null +++ b/test/runtime/samples/await-without-catch/main.svelte @@ -0,0 +1,9 @@ + + +{#await promise} +

loading...

+{:then value} +

loaded

+{/await} \ No newline at end of file diff --git a/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js b/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js index d4c2b7cd0f..158536b5fb 100644 --- a/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js +++ b/test/runtime/samples/binding-audio-currenttime-duration-volume/_config.js @@ -8,6 +8,7 @@ export default { assert.equal(component.t, 0); assert.equal(component.d, 0); assert.equal(component.v, 0.5); + assert.equal(component.m, true); assert.equal(component.r, 1); assert.equal(component.paused, true); @@ -20,6 +21,7 @@ export default { audio.currentTime = 10; audio.duration = 20; audio.volume = 0.75; + audio.muted = false; audio.playbackRate = 2; audio.dispatchEvent(timeupdate); audio.dispatchEvent(durationchange); @@ -30,6 +32,7 @@ export default { assert.equal(component.t, 10); assert.equal(component.d, 0); // not 20, because read-only. Not sure how to test this! assert.equal(component.v, 0.75); + assert.equal(component.m, false); assert.equal(component.r, 2); assert.equal(component.paused, true); // ditto... } diff --git a/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte b/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte index 69335182e8..e232c920bf 100644 --- a/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte +++ b/test/runtime/samples/binding-audio-currenttime-duration-volume/main.svelte @@ -4,7 +4,8 @@ export let paused; export let v; export let r; + export let m; - \ No newline at end of file diff --git a/test/runtime/samples/binding-contenteditable-html-initial/_config.js b/test/runtime/samples/binding-contenteditable-html-initial/_config.js index 9eac2c9b17..4c30a3231a 100644 --- a/test/runtime/samples/binding-contenteditable-html-initial/_config.js +++ b/test/runtime/samples/binding-contenteditable-html-initial/_config.js @@ -36,5 +36,5 @@ export default { goodbye

hello goodbye

`); - }, + } }; diff --git a/test/runtime/samples/binding-contenteditable-html/_config.js b/test/runtime/samples/binding-contenteditable-html/_config.js index ceb6a75c70..639572faea 100644 --- a/test/runtime/samples/binding-contenteditable-html/_config.js +++ b/test/runtime/samples/binding-contenteditable-html/_config.js @@ -1,6 +1,6 @@ export default { props: { - name: 'world', + name: 'world' }, html: ` @@ -34,5 +34,5 @@ export default { goodbye

hello goodbye

`); - }, + } }; diff --git a/test/runtime/samples/binding-contenteditable-text-initial/_config.js b/test/runtime/samples/binding-contenteditable-text-initial/_config.js index 4899f30f12..d5f331bb7a 100644 --- a/test/runtime/samples/binding-contenteditable-text-initial/_config.js +++ b/test/runtime/samples/binding-contenteditable-text-initial/_config.js @@ -30,5 +30,5 @@ export default { goodbye

hello goodbye

`); - }, + } }; diff --git a/test/runtime/samples/binding-contenteditable-text/_config.js b/test/runtime/samples/binding-contenteditable-text/_config.js index 9f8645724d..89f3968258 100644 --- a/test/runtime/samples/binding-contenteditable-text/_config.js +++ b/test/runtime/samples/binding-contenteditable-text/_config.js @@ -1,6 +1,6 @@ export default { props: { - name: 'world', + name: 'world' }, html: ` @@ -28,5 +28,5 @@ export default { goodbye

hello goodbye

`); - }, + } }; diff --git a/test/runtime/samples/binding-indirect-computed/_config.js b/test/runtime/samples/binding-indirect-computed/_config.js index 9834d0a228..860adf80f0 100644 --- a/test/runtime/samples/binding-indirect-computed/_config.js +++ b/test/runtime/samples/binding-indirect-computed/_config.js @@ -39,4 +39,4 @@ export default { B `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/binding-indirect/_config.js b/test/runtime/samples/binding-indirect/_config.js index a0a610f43f..e0f10b94bd 100644 --- a/test/runtime/samples/binding-indirect/_config.js +++ b/test/runtime/samples/binding-indirect/_config.js @@ -87,4 +87,4 @@ export default {

shake it all about

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js b/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js index 2e3a1c296f..9d099feb0a 100644 --- a/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js +++ b/test/runtime/samples/binding-input-checkbox-indeterminate/_config.js @@ -2,7 +2,7 @@ export default { skip_if_ssr: true, props: { - indeterminate: true, + indeterminate: true }, html: ` @@ -38,5 +38,5 @@ export default {

checked? true

indeterminate? true

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js b/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js index b502ed40af..1247414c1c 100644 --- a/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js +++ b/test/runtime/samples/binding-input-checkbox-with-event-in-each/_config.js @@ -2,14 +2,14 @@ export default { props: { cats: [ { - name: "cat 0", - checked: false, + name: 'cat 0', + checked: false }, { - name: "cat 1", - checked: false, - }, - ], + name: 'cat 1', + checked: false + } + ] }, html: ` @@ -21,8 +21,8 @@ export default { const { cats } = component; const newCats = cats.slice(); newCats.push({ - name: "cat " + cats.length, - checked: false, + name: 'cat ' + cats.length, + checked: false }); component.cats = newCats; diff --git a/test/runtime/samples/binding-input-group-duplicate-value/_config.js b/test/runtime/samples/binding-input-group-duplicate-value/_config.js new file mode 100644 index 0000000000..b5f3ae0115 --- /dev/null +++ b/test/runtime/samples/binding-input-group-duplicate-value/_config.js @@ -0,0 +1,81 @@ +export default { + html: ` +

Checked:

+ +
+ + a
+ b
+ c
+ d
+ +
+ + a
+ b
+ c
+ d
+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + const p = target.querySelector('p'); + + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + assert.equal(inputs[3].checked, false); + + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, false); + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + + const event = new window.Event('change'); + + inputs[0].checked = true; + await inputs[0].dispatchEvent(event); + + assert.htmlEqual(p.innerHTML, 'Checked: a'); + + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + assert.equal(inputs[3].checked, false); + + assert.equal(inputs[4].checked, true); + assert.equal(inputs[5].checked, false); + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + + inputs[3].checked = true; + await inputs[3].dispatchEvent(event); + + assert.htmlEqual(p.innerHTML, 'Checked: a,d'); + + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + assert.equal(inputs[3].checked, true); + + assert.equal(inputs[4].checked, true); + assert.equal(inputs[5].checked, false); + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, true); + + inputs[4].checked = false; + await inputs[4].dispatchEvent(event); + + assert.htmlEqual(p.innerHTML, 'Checked: d'); + + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + assert.equal(inputs[3].checked, true); + + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, false); + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, true); + } +}; diff --git a/test/runtime/samples/binding-input-group-duplicate-value/main.svelte b/test/runtime/samples/binding-input-group-duplicate-value/main.svelte new file mode 100644 index 0000000000..153e559d23 --- /dev/null +++ b/test/runtime/samples/binding-input-group-duplicate-value/main.svelte @@ -0,0 +1,19 @@ + + +

Checked: {foo}

+ +
+ +a
+b
+c
+d
+ +
+ +a
+b
+c
+d
\ No newline at end of file diff --git a/test/runtime/samples/binding-input-group-each-1/_config.js b/test/runtime/samples/binding-input-group-each-1/_config.js new file mode 100644 index 0000000000..92010296dc --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-1/_config.js @@ -0,0 +1,275 @@ +const values = [ + { name: 'Alpha' }, + { name: 'Beta' }, + { name: 'Gamma' } +]; + +const selected_array = [ + [values[1]], + [], + [values[2]] +]; + +export default { + props: { + values, + selected_array + }, + + html: ` +
+ + + + + + +

Beta

+
+
+ + + + + + +

+
+
+ + + + + + +

Gamma

+
+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, false); + assert.equal(inputs[3].checked, false); + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, false); + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, true); + + const event = new window.Event('change'); + + inputs[0].checked = true; + await inputs[0].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Alpha, Beta

+
+
+ + + + + + +

+
+
+ + + + + + +

Gamma

+
+ `); + inputs[3].checked = true; + await inputs[3].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Alpha, Beta

+
+
+ + + + + + +

Alpha

+
+
+ + + + + + +

Gamma

+
+ `); + + inputs[8].checked = false; + await inputs[8].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Alpha, Beta

+
+
+ + + + + + +

Alpha

+
+
+ + + + + + +

+
+ `); + + component.selected_array = [[values[1], values[2]], [values[2]]]; + + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, true); + assert.equal(inputs[3].checked, false); + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, true); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Beta, Gamma

+
+
+ + + + + + +

Gamma

+
+ `); + } +}; diff --git a/test/runtime/samples/binding-input-group-each-1/main.svelte b/test/runtime/samples/binding-input-group-each-1/main.svelte new file mode 100644 index 0000000000..5ed255c83a --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-1/main.svelte @@ -0,0 +1,15 @@ + + +{#each selected_array as selected} +
+ {#each values as value} + + {/each} +

{selected.map(v => v.name).join(', ')}

+
+{/each} diff --git a/test/runtime/samples/binding-input-group-each-2/_config.js b/test/runtime/samples/binding-input-group-each-2/_config.js new file mode 100644 index 0000000000..78d692d979 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-2/_config.js @@ -0,0 +1,59 @@ +export default { + html: ` + + + + +

1, 2, 3

`, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, true); + + const event = new window.Event('change'); + + inputs[0].checked = false; + await inputs[0].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + + +

2, 3

+ `); + + component.selected = [[1, 3]]; + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, true); + + assert.htmlEqual(target.innerHTML, ` + + + + +

1, 3

+ `); + } +}; diff --git a/test/runtime/samples/binding-input-group-each-2/main.svelte b/test/runtime/samples/binding-input-group-each-2/main.svelte new file mode 100644 index 0000000000..46f7e9e698 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-2/main.svelte @@ -0,0 +1,17 @@ + + +{#each options as value} + +{/each} + +

{selected[0].join(', ')}

\ No newline at end of file diff --git a/test/runtime/samples/binding-input-group-each-3/_config.js b/test/runtime/samples/binding-input-group-each-3/_config.js new file mode 100644 index 0000000000..92010296dc --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-3/_config.js @@ -0,0 +1,275 @@ +const values = [ + { name: 'Alpha' }, + { name: 'Beta' }, + { name: 'Gamma' } +]; + +const selected_array = [ + [values[1]], + [], + [values[2]] +]; + +export default { + props: { + values, + selected_array + }, + + html: ` +
+ + + + + + +

Beta

+
+
+ + + + + + +

+
+
+ + + + + + +

Gamma

+
+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, false); + assert.equal(inputs[3].checked, false); + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, false); + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, true); + + const event = new window.Event('change'); + + inputs[0].checked = true; + await inputs[0].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Alpha, Beta

+
+
+ + + + + + +

+
+
+ + + + + + +

Gamma

+
+ `); + inputs[3].checked = true; + await inputs[3].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Alpha, Beta

+
+
+ + + + + + +

Alpha

+
+
+ + + + + + +

Gamma

+
+ `); + + inputs[8].checked = false; + await inputs[8].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Alpha, Beta

+
+
+ + + + + + +

Alpha

+
+
+ + + + + + +

+
+ `); + + component.selected_array = [[values[1], values[2]], [values[2]]]; + + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, true); + assert.equal(inputs[3].checked, false); + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, true); + + assert.htmlEqual(target.innerHTML, ` +
+ + + + + + +

Beta, Gamma

+
+
+ + + + + + +

Gamma

+
+ `); + } +}; diff --git a/test/runtime/samples/binding-input-group-each-3/main.svelte b/test/runtime/samples/binding-input-group-each-3/main.svelte new file mode 100644 index 0000000000..42a7a1c4e9 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-3/main.svelte @@ -0,0 +1,15 @@ + + +{#each selected_array as _, index} +
+ {#each values as value} + + {/each} +

{selected_array[index].map(v => v.name).join(', ')}

+
+{/each} diff --git a/test/runtime/samples/binding-input-group-each-4/_config.js b/test/runtime/samples/binding-input-group-each-4/_config.js new file mode 100644 index 0000000000..f1168858b0 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-4/_config.js @@ -0,0 +1,153 @@ +export default { + html: ` + + + +

1

+ + + +

2

+ + + +

+ + + +

3

+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + + assert.equal(inputs[3].checked, false); + assert.equal(inputs[4].checked, true); + assert.equal(inputs[5].checked, false); + + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, false); + + assert.equal(inputs[9].checked, false); + assert.equal(inputs[10].checked, false); + assert.equal(inputs[11].checked, true); + + const event = new window.Event('change'); + + inputs[2].checked = true; + await inputs[2].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 3

+ + + +

2

+ + + +

+ + + +

3

+ `); + + inputs[9].checked = true; + await inputs[9].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 3

+ + + +

2

+ + + +

+ + + +

1, 3

+ `); + + inputs[4].checked = false; + await inputs[4].dispatchEvent(event); + inputs[5].checked = true; + await inputs[5].dispatchEvent(event); + inputs[6].checked = true; + await inputs[6].dispatchEvent(event); + inputs[7].checked = true; + await inputs[7].dispatchEvent(event); + inputs[11].checked = false; + await inputs[11].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 3

+ + + +

3

+ + + +

1, 2

+ + + +

1

+ `); + + component.selected_array_1 = [[3], [1]]; + component.selected_array_2 = [[], [2]]; + + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, true); + + assert.equal(inputs[3].checked, true); + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, false); + + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, false); + + assert.equal(inputs[9].checked, false); + assert.equal(inputs[10].checked, true); + assert.equal(inputs[11].checked, false); + + assert.htmlEqual(target.innerHTML, ` + + + +

3

+ + + +

1

+ + + +

+ + + +

2

+ `); + } +}; diff --git a/test/runtime/samples/binding-input-group-each-4/main.svelte b/test/runtime/samples/binding-input-group-each-4/main.svelte new file mode 100644 index 0000000000..0bbf5ea763 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-4/main.svelte @@ -0,0 +1,33 @@ + + +{#each selected_array_1 as selected} + {#each options as value} + + {/each} +

{selected.join(', ')}

+{/each} + +{#each selected_array_2 as selected} + {#each options as value} + + {/each} +

{selected.join(', ')}

+{/each} \ No newline at end of file diff --git a/test/runtime/samples/binding-input-group-each-5/_config.js b/test/runtime/samples/binding-input-group-each-5/_config.js new file mode 100644 index 0000000000..579225c627 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-5/_config.js @@ -0,0 +1,160 @@ +export default { + html: ` + + + +

1

+ + + +

1, 2, 3

+ + + +

2

+ + + +

1

+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + + assert.equal(inputs[3].checked, true); + assert.equal(inputs[4].checked, true); + assert.equal(inputs[5].checked, true); + + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, true); + assert.equal(inputs[8].checked, false); + + assert.equal(inputs[9].checked, true); + assert.equal(inputs[10].checked, false); + assert.equal(inputs[11].checked, false); + + const event = new window.Event('change'); + + inputs[2].checked = true; + await inputs[2].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 3

+ + + +

1, 2, 3

+ + + +

2

+ + + +

1

+ `); + + inputs[8].checked = true; + await inputs[8].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 3

+ + + +

1, 2, 3

+ + + +

2, 3

+ + + +

1

+ `); + + component.selected_index = [1, 1]; + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 2, 3

+ + + +

1, 2, 3

+ + + +

1

+ + + +

1

+ `); + + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, true); + + assert.equal(inputs[3].checked, true); + assert.equal(inputs[4].checked, true); + assert.equal(inputs[5].checked, true); + + assert.equal(inputs[6].checked, true); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, false); + + assert.equal(inputs[9].checked, true); + assert.equal(inputs[10].checked, false); + assert.equal(inputs[11].checked, false); + + inputs[5].checked = false; + await inputs[5].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

1, 2

+ + + +

1, 2

+ + + +

1

+ + + +

1

+ `); + + assert.equal(inputs[0].checked, true); + assert.equal(inputs[1].checked, true); + assert.equal(inputs[2].checked, false); + + assert.equal(inputs[3].checked, true); + assert.equal(inputs[4].checked, true); + assert.equal(inputs[5].checked, false); + + assert.equal(inputs[6].checked, true); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, false); + + assert.equal(inputs[9].checked, true); + assert.equal(inputs[10].checked, false); + assert.equal(inputs[11].checked, false); + } +}; diff --git a/test/runtime/samples/binding-input-group-each-5/main.svelte b/test/runtime/samples/binding-input-group-each-5/main.svelte new file mode 100644 index 0000000000..93bdce6510 --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-5/main.svelte @@ -0,0 +1,24 @@ + + +{#each selected_array as selected} + {#each selected_index as index} + {#each options as value} + + {/each} +

{selected[index].join(', ')}

+ {/each} +{/each} diff --git a/test/runtime/samples/binding-input-group-each-6/_config.js b/test/runtime/samples/binding-input-group-each-6/_config.js new file mode 100644 index 0000000000..9eb251bf5d --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-6/_config.js @@ -0,0 +1,87 @@ +export default { + html: ` + + + +

+ + + +

+ + + +

+ `, + + async test({ assert, component, target, window }) { + const inputs = target.querySelectorAll('input'); + assert.equal(inputs[0].checked, false); + assert.equal(inputs[1].checked, false); + assert.equal(inputs[2].checked, false); + + assert.equal(inputs[3].checked, false); + assert.equal(inputs[4].checked, false); + assert.equal(inputs[5].checked, false); + + assert.equal(inputs[6].checked, false); + assert.equal(inputs[7].checked, false); + assert.equal(inputs[8].checked, false); + + const event = new window.Event('change'); + + inputs[2].checked = true; + await inputs[2].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

z

+ + + +

+ + + +

+ `); + + inputs[4].checked = true; + await inputs[4].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

z

+ + + +

y

+ + + +

+ `); + + inputs[5].checked = true; + await inputs[5].dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + + + +

z

+ + + +

y, z

+ + + +

+ `); + } +}; diff --git a/test/runtime/samples/binding-input-group-each-6/main.svelte b/test/runtime/samples/binding-input-group-each-6/main.svelte new file mode 100644 index 0000000000..85be939e8a --- /dev/null +++ b/test/runtime/samples/binding-input-group-each-6/main.svelte @@ -0,0 +1,22 @@ + + +{#each Object.keys(list) as key} + {#each values as value} + + {/each} +

{list[key].join(', ')}

+{/each} diff --git a/test/runtime/samples/binding-input-number-2/_config.js b/test/runtime/samples/binding-input-number-2/_config.js new file mode 100644 index 0000000000..4411eac0b2 --- /dev/null +++ b/test/runtime/samples/binding-input-number-2/_config.js @@ -0,0 +1,31 @@ +export default { + test({ assert, target, window, component }) { + const input = target.querySelector('input'); + const inputEvent = new window.InputEvent('input'); + assert.equal(component.value, 5); + assert.equal(input.value, '5'); + + input.value = '5.'; + input.dispatchEvent(inputEvent); + + // input type number has value === "" if ends with dot/comma + assert.equal(component.value, undefined); + assert.equal(input.value, ''); + + input.value = '5.5'; + input.dispatchEvent(inputEvent); + + assert.equal(component.value, 5.5); + assert.equal(input.value, '5.5'); + + input.value = '5.50'; + input.dispatchEvent(inputEvent); + + assert.equal(component.value, 5.5); + assert.equal(input.value, '5.50'); + + component.value = 1; + assert.equal(component.value, 1); + assert.equal(input.value, '1'); + } +}; diff --git a/test/runtime/samples/binding-input-number-2/main.svelte b/test/runtime/samples/binding-input-number-2/main.svelte new file mode 100644 index 0000000000..62119547a0 --- /dev/null +++ b/test/runtime/samples/binding-input-number-2/main.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/runtime/samples/binding-input-number/_config.js b/test/runtime/samples/binding-input-number/_config.js index 869b9f9896..1a56a75c0c 100644 --- a/test/runtime/samples/binding-input-number/_config.js +++ b/test/runtime/samples/binding-input-number/_config.js @@ -1,6 +1,6 @@ export default { props: { - count: 42, + count: 42 }, html: ` @@ -35,14 +35,14 @@ export default {

number 44

`); - // empty string should be treated as undefined + // empty string should be treated as null input.value = ''; await input.dispatchEvent(event); - assert.equal(component.count, undefined); + assert.equal(component.count, null); assert.htmlEqual(target.innerHTML, ` -

undefined undefined

+

object null

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-range-change-with-max/_config.js b/test/runtime/samples/binding-input-range-change-with-max/_config.js index 1fda90d83c..dc3cf4ce28 100644 --- a/test/runtime/samples/binding-input-range-change-with-max/_config.js +++ b/test/runtime/samples/binding-input-range-change-with-max/_config.js @@ -29,5 +29,5 @@ export default {

20 of 20

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-range-change/_config.js b/test/runtime/samples/binding-input-range-change/_config.js index 62e9562770..f6ec2d9c53 100644 --- a/test/runtime/samples/binding-input-range-change/_config.js +++ b/test/runtime/samples/binding-input-range-change/_config.js @@ -1,6 +1,6 @@ export default { props: { - count: 42, + count: 42 }, html: ` @@ -34,5 +34,5 @@ export default {

number 44

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-range/_config.js b/test/runtime/samples/binding-input-range/_config.js index 4c3d37a667..dc6178e088 100644 --- a/test/runtime/samples/binding-input-range/_config.js +++ b/test/runtime/samples/binding-input-range/_config.js @@ -1,6 +1,6 @@ export default { props: { - count: 42, + count: 42 }, html: ` @@ -34,5 +34,5 @@ export default {

number 44

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js b/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js index 28cffdfa57..de4d6325b0 100644 --- a/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js +++ b/test/runtime/samples/binding-input-text-contextual-deconflicted/_config.js @@ -1,7 +1,7 @@ export default { props: { foo: 'a', - items: ['x'], + items: ['x'] }, html: ` @@ -32,5 +32,5 @@ export default {

b

y

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-contextual-reactive/_config.js b/test/runtime/samples/binding-input-text-contextual-reactive/_config.js index 6fdfc4be52..a1584c18b8 100644 --- a/test/runtime/samples/binding-input-text-contextual-reactive/_config.js +++ b/test/runtime/samples/binding-input-text-contextual-reactive/_config.js @@ -121,5 +121,5 @@ export default {

done:one / done:two / remaining:four

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-contextual/_config.js b/test/runtime/samples/binding-input-text-contextual/_config.js index bb7f16c8bb..1c66ea7ff5 100644 --- a/test/runtime/samples/binding-input-text-contextual/_config.js +++ b/test/runtime/samples/binding-input-text-contextual/_config.js @@ -1,6 +1,6 @@ export default { props: { - items: ['one', 'two', 'three'], + items: ['one', 'two', 'three'] }, html: ` @@ -65,5 +65,5 @@ export default {

five

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-deconflicted/_config.js b/test/runtime/samples/binding-input-text-deconflicted/_config.js index 46fe3e2a38..48a7d2590a 100644 --- a/test/runtime/samples/binding-input-text-deconflicted/_config.js +++ b/test/runtime/samples/binding-input-text-deconflicted/_config.js @@ -1,8 +1,8 @@ export default { props: { component: { - name: 'world', - }, + name: 'world' + } }, html: ` @@ -36,5 +36,5 @@ export default {

Hello goodbye!

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-deep-computed-dynamic/_config.js b/test/runtime/samples/binding-input-text-deep-computed-dynamic/_config.js index eeecdb0ef8..0afbb9d952 100644 --- a/test/runtime/samples/binding-input-text-deep-computed-dynamic/_config.js +++ b/test/runtime/samples/binding-input-text-deep-computed-dynamic/_config.js @@ -4,8 +4,8 @@ export default { obj: { foo: 'a', bar: 'b', - baz: 'c', - }, + baz: 'c' + } }, html: ` @@ -56,5 +56,5 @@ export default {
{"foo":"d","bar":"e","baz":"f"}
`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-deep-computed/_config.js b/test/runtime/samples/binding-input-text-deep-computed/_config.js index a1ea2c34ad..3a85d50d76 100644 --- a/test/runtime/samples/binding-input-text-deep-computed/_config.js +++ b/test/runtime/samples/binding-input-text-deep-computed/_config.js @@ -2,8 +2,8 @@ export default { props: { prop: 'name', user: { - name: 'alice', - }, + name: 'alice' + } }, html: ` @@ -40,5 +40,5 @@ export default {

hello carol

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/_config.js b/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/_config.js index 364195233d..627ef5f15e 100644 --- a/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/_config.js +++ b/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/_config.js @@ -5,9 +5,9 @@ export default { { foo: 'a', bar: 'b', - baz: 'c', - }, - ], + baz: 'c' + } + ] }, html: ` @@ -58,5 +58,5 @@ export default {
{"foo":"d","bar":"e","baz":"f"}
`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-deep-contextual/_config.js b/test/runtime/samples/binding-input-text-deep-contextual/_config.js index 5b6b0d6577..cc80d38042 100644 --- a/test/runtime/samples/binding-input-text-deep-contextual/_config.js +++ b/test/runtime/samples/binding-input-text-deep-contextual/_config.js @@ -3,8 +3,8 @@ export default { items: [ { description: 'one' }, { description: 'two' }, - { description: 'three' }, - ], + { description: 'three' } + ] }, html: ` @@ -45,5 +45,5 @@ export default {

four

five

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-deep/_config.js b/test/runtime/samples/binding-input-text-deep/_config.js index e6113510a7..35443e9073 100644 --- a/test/runtime/samples/binding-input-text-deep/_config.js +++ b/test/runtime/samples/binding-input-text-deep/_config.js @@ -1,8 +1,8 @@ export default { props: { user: { - name: 'alice', - }, + name: 'alice' + } }, html: ` @@ -39,5 +39,5 @@ export default {

hello carol

`); - }, + } }; diff --git a/test/runtime/samples/binding-input-text-undefined/_config.js b/test/runtime/samples/binding-input-text-undefined/_config.js new file mode 100644 index 0000000000..fa59b1f796 --- /dev/null +++ b/test/runtime/samples/binding-input-text-undefined/_config.js @@ -0,0 +1,30 @@ +export default { + html: ` + + `, + + ssrHtml: ` + + `, + + async test({ assert, component, target, window }) { + const input = target.querySelector('input'); + assert.equal(input.value, ''); + + component.x = null; + assert.equal(input.value, ''); + + component.x = undefined; + assert.equal(input.value, ''); + + component.x = 'string'; + component.x = undefined; + assert.equal(input.value, ''); + + component.x = 0; + assert.equal(input.value, '0'); + + component.x = undefined; + assert.equal(input.value, ''); + } +}; diff --git a/test/runtime/samples/binding-input-text-undefined/main.svelte b/test/runtime/samples/binding-input-text-undefined/main.svelte new file mode 100644 index 0000000000..b4c2a84fd2 --- /dev/null +++ b/test/runtime/samples/binding-input-text-undefined/main.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/binding-input-text/_config.js b/test/runtime/samples/binding-input-text/_config.js index e7162b6153..52d8e44902 100644 --- a/test/runtime/samples/binding-input-text/_config.js +++ b/test/runtime/samples/binding-input-text/_config.js @@ -1,6 +1,6 @@ export default { props: { - name: 'world', + name: 'world' }, html: ` @@ -33,5 +33,5 @@ export default {

hello goodbye

`); - }, + } }; diff --git a/test/runtime/samples/binding-select-in-yield/_config.js b/test/runtime/samples/binding-select-in-yield/_config.js index 11dcb3d58c..042fba832b 100644 --- a/test/runtime/samples/binding-select-in-yield/_config.js +++ b/test/runtime/samples/binding-select-in-yield/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', props: { letter: 'b' diff --git a/test/runtime/samples/binding-select-initial-value/_config.js b/test/runtime/samples/binding-select-initial-value/_config.js index d98e5d2e1c..d34a987fa5 100644 --- a/test/runtime/samples/binding-select-initial-value/_config.js +++ b/test/runtime/samples/binding-select-initial-value/_config.js @@ -24,7 +24,7 @@ export default { `, props: { - selected: 'b', + selected: 'b' }, test({ assert, component, target }) { @@ -33,5 +33,5 @@ export default { assert.equal(select.value, 'b'); assert.ok(options[1].selected); - }, + } }; diff --git a/test/runtime/samples/binding-select-late-2/_config.js b/test/runtime/samples/binding-select-late-2/_config.js new file mode 100644 index 0000000000..42c45d1366 --- /dev/null +++ b/test/runtime/samples/binding-select-late-2/_config.js @@ -0,0 +1,34 @@ +export default { + props: { + items: [], + selected: 'two' + }, + + html: ` + +

selected: two

+ `, + + ssrHtml: ` + +

selected: two

+ `, + + test({ assert, component, target }) { + component.items = [ 'one', 'two', 'three' ]; + + const options = target.querySelectorAll('option'); + assert.ok(!options[0].selected); + assert.ok(options[1].selected); + assert.ok(!options[2].selected); + + assert.htmlEqual(target.innerHTML, ` + +

selected: two

+ `); + } +}; diff --git a/test/runtime/samples/binding-select-late-2/main.svelte b/test/runtime/samples/binding-select-late-2/main.svelte new file mode 100644 index 0000000000..52cc14528a --- /dev/null +++ b/test/runtime/samples/binding-select-late-2/main.svelte @@ -0,0 +1,12 @@ + + + + +

selected: {selected || 'nothing'}

\ No newline at end of file diff --git a/test/runtime/samples/binding-select-late-3/_config.js b/test/runtime/samples/binding-select-late-3/_config.js new file mode 100644 index 0000000000..42c45d1366 --- /dev/null +++ b/test/runtime/samples/binding-select-late-3/_config.js @@ -0,0 +1,34 @@ +export default { + props: { + items: [], + selected: 'two' + }, + + html: ` + +

selected: two

+ `, + + ssrHtml: ` + +

selected: two

+ `, + + test({ assert, component, target }) { + component.items = [ 'one', 'two', 'three' ]; + + const options = target.querySelectorAll('option'); + assert.ok(!options[0].selected); + assert.ok(options[1].selected); + assert.ok(!options[2].selected); + + assert.htmlEqual(target.innerHTML, ` + +

selected: two

+ `); + } +}; diff --git a/test/runtime/samples/binding-select-late-3/main.svelte b/test/runtime/samples/binding-select-late-3/main.svelte new file mode 100644 index 0000000000..ec9ac8d345 --- /dev/null +++ b/test/runtime/samples/binding-select-late-3/main.svelte @@ -0,0 +1,12 @@ + + + + +

selected: {selected || 'nothing'}

\ No newline at end of file diff --git a/test/runtime/samples/binding-select-optgroup/_config.js b/test/runtime/samples/binding-select-optgroup/_config.js index e8a1d40797..03ad3e3280 100644 --- a/test/runtime/samples/binding-select-optgroup/_config.js +++ b/test/runtime/samples/binding-select-optgroup/_config.js @@ -45,5 +45,5 @@ export default { `); - }, + } }; diff --git a/test/runtime/samples/binding-select/_config.js b/test/runtime/samples/binding-select/_config.js index a5995061a0..310315176b 100644 --- a/test/runtime/samples/binding-select/_config.js +++ b/test/runtime/samples/binding-select/_config.js @@ -24,7 +24,7 @@ export default { `, props: { - selected: 'one', + selected: 'one' }, async test({ assert, component, target, window }) { @@ -53,5 +53,5 @@ export default { `); component.selected = 'three'; - }, + } }; diff --git a/test/runtime/samples/binding-store-deep/_config.js b/test/runtime/samples/binding-store-deep/_config.js index 8bdd41818b..c0f4f63578 100644 --- a/test/runtime/samples/binding-store-deep/_config.js +++ b/test/runtime/samples/binding-store-deep/_config.js @@ -37,5 +37,5 @@ export default { assert.deepEqual(names, ['world', 'everybody', 'goodbye']); unsubscribe(); - }, + } }; diff --git a/test/runtime/samples/binding-store/_config.js b/test/runtime/samples/binding-store/_config.js index eb22d3e96c..6e7a70878a 100644 --- a/test/runtime/samples/binding-store/_config.js +++ b/test/runtime/samples/binding-store/_config.js @@ -37,5 +37,5 @@ export default { assert.deepEqual(names, ['world', 'everybody', 'goodbye']); unsubscribe(); - }, + } }; diff --git a/test/runtime/samples/binding-textarea/_config.js b/test/runtime/samples/binding-textarea/_config.js index ac092096e6..70646e5e4b 100644 --- a/test/runtime/samples/binding-textarea/_config.js +++ b/test/runtime/samples/binding-textarea/_config.js @@ -1,6 +1,6 @@ export default { props: { - value: 'some text', + value: 'some text' }, html: ` @@ -33,5 +33,5 @@ export default {

goodbye

`); - }, + } }; diff --git a/test/runtime/samples/binding-this-each-block-property-2/_config.js b/test/runtime/samples/binding-this-each-block-property-2/_config.js new file mode 100644 index 0000000000..b67d27050e --- /dev/null +++ b/test/runtime/samples/binding-this-each-block-property-2/_config.js @@ -0,0 +1,53 @@ +let calls = []; +function callback(refs) { + calls.push(refs.map(({ ref }) => ({ ref }))); +} +export default { + html: '', + props: { + callback + }, + after_test() { + calls = []; + }, + async test({ assert, component, target }) { + assert.equal(calls.length, 1); + assert.equal(calls[0].length, 0); + + await component.addItem(); + + let divs = target.querySelectorAll('div'); + + assert.equal(calls.length, 3); + assert.equal(calls[1].length, 1); + assert.equal(calls[1][0].ref, null); + assert.equal(calls[2].length, 1); + assert.equal(calls[2][0].ref, divs[0]); + + await component.addItem(); + + divs = target.querySelectorAll('div'); + + assert.equal(calls.length, 5); + assert.equal(calls[3].length, 2); + assert.equal(calls[3][0].ref, divs[0]); + assert.equal(calls[3][1].ref, null); + assert.equal(calls[4].length, 2); + assert.equal(calls[4][0].ref, divs[0]); + assert.equal(calls[4][1].ref, divs[1]); + + await component.addItem(); + + divs = target.querySelectorAll('div'); + + assert.equal(calls.length, 7); + assert.equal(calls[5].length, 3); + assert.equal(calls[5][0].ref, divs[0]); + assert.equal(calls[5][1].ref, divs[1]); + assert.equal(calls[5][2].ref, null); + assert.equal(calls[6].length, 3); + assert.equal(calls[6][0].ref, divs[0]); + assert.equal(calls[6][1].ref, divs[1]); + assert.equal(calls[6][2].ref, divs[2]); + } +}; diff --git a/test/runtime/samples/binding-this-each-block-property-2/main.svelte b/test/runtime/samples/binding-this-each-block-property-2/main.svelte new file mode 100644 index 0000000000..bc1efe725c --- /dev/null +++ b/test/runtime/samples/binding-this-each-block-property-2/main.svelte @@ -0,0 +1,17 @@ + + +{#each refs as xxx} +
+{/each} \ No newline at end of file diff --git a/test/runtime/samples/binding-this-each-block-property-component/_config.js b/test/runtime/samples/binding-this-each-block-property-component/_config.js index 947ec17929..3346888555 100644 --- a/test/runtime/samples/binding-this-each-block-property-component/_config.js +++ b/test/runtime/samples/binding-this-each-block-property-component/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', async test({ assert, component, target }) { component.visible = true; diff --git a/test/runtime/samples/binding-this-each-block-property/_config.js b/test/runtime/samples/binding-this-each-block-property/_config.js index 15ad4be5db..bb24bcc0bf 100644 --- a/test/runtime/samples/binding-this-each-block-property/_config.js +++ b/test/runtime/samples/binding-this-each-block-property/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', async test({ assert, component, target }) { component.visible = true; diff --git a/test/runtime/samples/binding-this-each-object-props/_config.js b/test/runtime/samples/binding-this-each-object-props/_config.js new file mode 100644 index 0000000000..e9ec7d90f0 --- /dev/null +++ b/test/runtime/samples/binding-this-each-object-props/_config.js @@ -0,0 +1,14 @@ +export default { + html: '', + + async test({ assert, component, target }) { + component.visible = true; + assert.htmlEqual(target.innerHTML, ` +
b
b
c
c
+ `); + assert.equal(component.items1[1], target.querySelector('div')); + assert.equal(component.items2[1], target.querySelector('div:nth-child(2)')); + assert.equal(component.items1[2], target.querySelector('div:nth-child(3)')); + assert.equal(component.items2[2], target.querySelector('div:last-child')); + } +}; diff --git a/test/runtime/samples/binding-this-each-object-props/main.svelte b/test/runtime/samples/binding-this-each-object-props/main.svelte new file mode 100644 index 0000000000..9654a58418 --- /dev/null +++ b/test/runtime/samples/binding-this-each-object-props/main.svelte @@ -0,0 +1,13 @@ + + +{#each data as item (item.id)} +
{item.text}
+
{item.text}
+{/each} diff --git a/test/runtime/samples/binding-this-each-object-spread/_config.js b/test/runtime/samples/binding-this-each-object-spread/_config.js new file mode 100644 index 0000000000..e88ebe8de5 --- /dev/null +++ b/test/runtime/samples/binding-this-each-object-spread/_config.js @@ -0,0 +1,14 @@ +export default { + html: '', + + async test({ assert, component, target }) { + component.visible = true; + assert.htmlEqual(target.innerHTML, ` +
a
a
b
b
+ `); + assert.equal(component.items1[1], target.querySelector('div')); + assert.equal(component.items2[1], target.querySelector('div:nth-child(2)')); + assert.equal(component.items1[2], target.querySelector('div:nth-child(3)')); + assert.equal(component.items2[2], target.querySelector('div:last-child')); + } +}; diff --git a/test/runtime/samples/binding-this-each-object-spread/main.svelte b/test/runtime/samples/binding-this-each-object-spread/main.svelte new file mode 100644 index 0000000000..256ed0ede6 --- /dev/null +++ b/test/runtime/samples/binding-this-each-object-spread/main.svelte @@ -0,0 +1,13 @@ + + +{#each data as {id, text} (id)} +
{text}
+
{text}
+{/each} diff --git a/test/runtime/samples/binding-this-store/_config.js b/test/runtime/samples/binding-this-store/_config.js index f818c2e31e..32bc9c4ce9 100644 --- a/test/runtime/samples/binding-this-store/_config.js +++ b/test/runtime/samples/binding-this-store/_config.js @@ -1,4 +1,4 @@ export default { skip_if_ssr: true, - html: `
object
` + html: '
object
' }; diff --git a/test/runtime/samples/binding-using-props/_config.js b/test/runtime/samples/binding-using-props/_config.js index dcb34c4357..2e5fef1f4f 100644 --- a/test/runtime/samples/binding-using-props/_config.js +++ b/test/runtime/samples/binding-using-props/_config.js @@ -11,4 +11,4 @@ export default {

changed

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/binding-width-height-a11y/_config.js b/test/runtime/samples/binding-width-height-a11y/_config.js index 5ab4a7ade7..198051e6d2 100644 --- a/test/runtime/samples/binding-width-height-a11y/_config.js +++ b/test/runtime/samples/binding-width-height-a11y/_config.js @@ -1,8 +1,8 @@ export default { async test({ assert, target }) { - const object = target.querySelector('object'); + const iframe = target.querySelector('iframe'); - assert.equal(object.getAttribute('aria-hidden'), "true"); - assert.equal(object.getAttribute('tabindex'), "-1"); + assert.equal(iframe.getAttribute('aria-hidden'), 'true'); + assert.equal(iframe.getAttribute('tabindex'), '-1'); } }; diff --git a/test/runtime/samples/bindings-before-onmount/_config.js b/test/runtime/samples/bindings-before-onmount/_config.js index d21751c528..1d2ac64fe8 100644 --- a/test/runtime/samples/bindings-before-onmount/_config.js +++ b/test/runtime/samples/bindings-before-onmount/_config.js @@ -2,4 +2,4 @@ export default { test({ assert, component }) { assert.equal(component.one.snapshot, 2); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bindings-coalesced/_config.js b/test/runtime/samples/bindings-coalesced/_config.js index 164d0b42e7..14ffd3ed89 100644 --- a/test/runtime/samples/bindings-coalesced/_config.js +++ b/test/runtime/samples/bindings-coalesced/_config.js @@ -14,4 +14,4 @@ export default { assert.deepEqual(values, ['6']); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bindings-global-dependency/_config.js b/test/runtime/samples/bindings-global-dependency/_config.js index 78e5a4b267..907aa52e6e 100644 --- a/test/runtime/samples/bindings-global-dependency/_config.js +++ b/test/runtime/samples/bindings-global-dependency/_config.js @@ -1,5 +1,4 @@ export default { html: '', - ssrHtml: '' -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bitmask-overflow-2/_config.js b/test/runtime/samples/bitmask-overflow-2/_config.js index 0b63791292..781c493245 100644 --- a/test/runtime/samples/bitmask-overflow-2/_config.js +++ b/test/runtime/samples/bitmask-overflow-2/_config.js @@ -1,3 +1,3 @@ export default { - error: `potato is not defined`, -}; \ No newline at end of file + error: 'potato is not defined' +}; diff --git a/test/runtime/samples/bitmask-overflow-3/_config.js b/test/runtime/samples/bitmask-overflow-3/_config.js index aee7d3237e..bd415bfd49 100644 --- a/test/runtime/samples/bitmask-overflow-3/_config.js +++ b/test/runtime/samples/bitmask-overflow-3/_config.js @@ -1,3 +1,3 @@ export default { - error: `A is not defined`, -}; \ No newline at end of file + error: 'A is not defined' +}; diff --git a/test/runtime/samples/bitmask-overflow-if/_config.js b/test/runtime/samples/bitmask-overflow-if/_config.js index 74bc70d414..49f48925c5 100644 --- a/test/runtime/samples/bitmask-overflow-if/_config.js +++ b/test/runtime/samples/bitmask-overflow-if/_config.js @@ -7,8 +7,8 @@ export default { `, async test({ assert, component, target, window }) { - const button = target.querySelector("button"); - await button.dispatchEvent(new window.MouseEvent("click")); + const button = target.querySelector('button'); + await button.dispatchEvent(new window.MouseEvent('click')); assert.htmlEqual( target.innerHTML, diff --git a/test/runtime/samples/bitmask-overflow-slot-2/_config.js b/test/runtime/samples/bitmask-overflow-slot-2/_config.js index b01bd81e00..1f9613711a 100644 --- a/test/runtime/samples/bitmask-overflow-slot-2/_config.js +++ b/test/runtime/samples/bitmask-overflow-slot-2/_config.js @@ -90,7 +90,7 @@ export default { assert.deepEqual(component.reads, { _0: 2, - _1: 2, + _1: 2 }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bitmask-overflow-slot-3/_config.js b/test/runtime/samples/bitmask-overflow-slot-3/_config.js index 93e548e5f7..7921253e18 100644 --- a/test/runtime/samples/bitmask-overflow-slot-3/_config.js +++ b/test/runtime/samples/bitmask-overflow-slot-3/_config.js @@ -27,4 +27,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bitmask-overflow-slot-4/_config.js b/test/runtime/samples/bitmask-overflow-slot-4/_config.js index cdaa5de77f..5aa339afd6 100644 --- a/test/runtime/samples/bitmask-overflow-slot-4/_config.js +++ b/test/runtime/samples/bitmask-overflow-slot-4/_config.js @@ -38,4 +38,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bitmask-overflow-slot-5/_config.js b/test/runtime/samples/bitmask-overflow-slot-5/_config.js index 7dedb8f7eb..80900d0042 100644 --- a/test/runtime/samples/bitmask-overflow-slot-5/_config.js +++ b/test/runtime/samples/bitmask-overflow-slot-5/_config.js @@ -46,4 +46,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bitmask-overflow-slot-6/Slotted.svelte b/test/runtime/samples/bitmask-overflow-slot-6/Slotted.svelte new file mode 100644 index 0000000000..322a31359e --- /dev/null +++ b/test/runtime/samples/bitmask-overflow-slot-6/Slotted.svelte @@ -0,0 +1,15 @@ + + +
+ + + + {#if open} + + {/if} +
diff --git a/test/runtime/samples/bitmask-overflow-slot-6/_config.js b/test/runtime/samples/bitmask-overflow-slot-6/_config.js new file mode 100644 index 0000000000..7cf7538b69 --- /dev/null +++ b/test/runtime/samples/bitmask-overflow-slot-6/_config.js @@ -0,0 +1,32 @@ +// overflow bitmask + slot missing `let:` +export default { + html: ` +
+ +
+ + `, + + async test({ assert, component, target, window }) { + const button = target.querySelectorAll('button')[1]; + const div = target.querySelector('div'); + await div.dispatchEvent(new window.MouseEvent('click')); + + assert.htmlEqual(target.innerHTML, ` +
+ +
Open
+
+ + `); + + await button.dispatchEvent(new window.MouseEvent('click')); + assert.htmlEqual(target.innerHTML, ` +
+ +
Open
+
+ + `); + } +}; diff --git a/test/runtime/samples/bitmask-overflow-slot-6/main.svelte b/test/runtime/samples/bitmask-overflow-slot-6/main.svelte new file mode 100644 index 0000000000..8845cb2ef5 --- /dev/null +++ b/test/runtime/samples/bitmask-overflow-slot-6/main.svelte @@ -0,0 +1,23 @@ + + + + + +
+ Open +
+
+ + \ No newline at end of file diff --git a/test/runtime/samples/bitmask-overflow-slot/_config.js b/test/runtime/samples/bitmask-overflow-slot/_config.js index 9b24d5541f..a14ef3270f 100644 --- a/test/runtime/samples/bitmask-overflow-slot/_config.js +++ b/test/runtime/samples/bitmask-overflow-slot/_config.js @@ -121,4 +121,4 @@ export default { _40: 1 }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/bitmask-overflow/_config.js b/test/runtime/samples/bitmask-overflow/_config.js index ada3195c81..e5e54ac10e 100644 --- a/test/runtime/samples/bitmask-overflow/_config.js +++ b/test/runtime/samples/bitmask-overflow/_config.js @@ -119,4 +119,4 @@ export default { _40: 1 }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/class-boolean/_config.js b/test/runtime/samples/class-boolean/_config.js index a5003566cc..ac02a1a425 100644 --- a/test/runtime/samples/class-boolean/_config.js +++ b/test/runtime/samples/class-boolean/_config.js @@ -1,3 +1,3 @@ export default { - html: `
` + html: '
' }; diff --git a/test/runtime/samples/class-helper/_config.js b/test/runtime/samples/class-helper/_config.js index c38cc88240..6a62476493 100644 --- a/test/runtime/samples/class-helper/_config.js +++ b/test/runtime/samples/class-helper/_config.js @@ -3,7 +3,7 @@ export default { user: { active: true } }, - html: `
`, + html: '
', test({ assert, component, target }) { component.user = { active: false }; diff --git a/test/runtime/samples/class-shortcut-with-class/_config.js b/test/runtime/samples/class-shortcut-with-class/_config.js index fc1a00e8aa..6d647e8f9d 100644 --- a/test/runtime/samples/class-shortcut-with-class/_config.js +++ b/test/runtime/samples/class-shortcut-with-class/_config.js @@ -5,7 +5,7 @@ export default { myClass: 'one two' }, - html: `
`, + html: '
', test({ assert, component, target, window }) { component.foo = false; diff --git a/test/runtime/samples/class-shortcut/_config.js b/test/runtime/samples/class-shortcut/_config.js index e0c8aec3a5..aba7e0e031 100644 --- a/test/runtime/samples/class-shortcut/_config.js +++ b/test/runtime/samples/class-shortcut/_config.js @@ -4,7 +4,7 @@ export default { bar: true }, - html: `
`, + html: '
', test({ assert, component, target, window }) { component.foo = false; diff --git a/test/runtime/samples/class-with-attribute/_config.js b/test/runtime/samples/class-with-attribute/_config.js index 719e6bd473..7550b215ab 100644 --- a/test/runtime/samples/class-with-attribute/_config.js +++ b/test/runtime/samples/class-with-attribute/_config.js @@ -1,3 +1,3 @@ export default { - html: `
` + html: '
' }; diff --git a/test/runtime/samples/class-with-dynamic-attribute-and-spread/_config.js b/test/runtime/samples/class-with-dynamic-attribute-and-spread/_config.js index 58ccc76497..f704e9327f 100644 --- a/test/runtime/samples/class-with-dynamic-attribute-and-spread/_config.js +++ b/test/runtime/samples/class-with-dynamic-attribute-and-spread/_config.js @@ -6,7 +6,7 @@ export default { } }, - html: `
`, + html: '
', test({ assert, component, target, window }) { component.myClass = 'one'; diff --git a/test/runtime/samples/class-with-dynamic-attribute/_config.js b/test/runtime/samples/class-with-dynamic-attribute/_config.js index 12c955c24d..2be6500674 100644 --- a/test/runtime/samples/class-with-dynamic-attribute/_config.js +++ b/test/runtime/samples/class-with-dynamic-attribute/_config.js @@ -3,7 +3,7 @@ export default { myClass: 'one two' }, - html: `
`, + html: '
', test({ assert, component, target, window }) { component.myClass = 'one'; diff --git a/test/runtime/samples/class-with-spread-and-bind/_config.js b/test/runtime/samples/class-with-spread-and-bind/_config.js index f3c54e8c52..7b50502f34 100644 --- a/test/runtime/samples/class-with-spread-and-bind/_config.js +++ b/test/runtime/samples/class-with-spread-and-bind/_config.js @@ -1,9 +1,9 @@ export default { props: { - primary: true, + primary: true }, - html: `
`, + html: '
', test({ assert, component, target, window }) { component.primary = true; @@ -14,5 +14,5 @@ export default {
` ); - }, + } }; diff --git a/test/runtime/samples/class-with-spread/_config.js b/test/runtime/samples/class-with-spread/_config.js index d5233a5849..c7c85e38b0 100644 --- a/test/runtime/samples/class-with-spread/_config.js +++ b/test/runtime/samples/class-with-spread/_config.js @@ -6,7 +6,7 @@ export default { } }, - html: `
`, + html: '
', test({ assert, component, target, window }) { component.myClass = 'one'; diff --git a/test/runtime/samples/component-binding-deep/_config.js b/test/runtime/samples/component-binding-deep/_config.js index be5a2624ac..8a2f5a56cf 100644 --- a/test/runtime/samples/component-binding-deep/_config.js +++ b/test/runtime/samples/component-binding-deep/_config.js @@ -21,5 +21,5 @@ export default {

blah

`); - }, + } }; diff --git a/test/runtime/samples/component-binding-store/Input.svelte b/test/runtime/samples/component-binding-store/Input.svelte new file mode 100644 index 0000000000..792104bec8 --- /dev/null +++ b/test/runtime/samples/component-binding-store/Input.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/component-binding-store/_config.js b/test/runtime/samples/component-binding-store/_config.js new file mode 100644 index 0000000000..d17b9e2d80 --- /dev/null +++ b/test/runtime/samples/component-binding-store/_config.js @@ -0,0 +1,61 @@ +export default { + html: ` + + +
+ `, + + async test({ assert, component, target, window }) { + let count = 0; + component.callback = () => { + count++; + }; + + const [input1, input2] = target.querySelectorAll('input'); + + input1.value = '1'; + await input1.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` + + +
1
+ ` + ); + assert.equal(input1.value, '1'); + assert.equal(input2.value, '1'); + assert.equal(count, 1); + + input2.value = '123'; + await input2.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` + + +
123
+ ` + ); + assert.equal(input1.value, '123'); + assert.equal(input2.value, '123'); + assert.equal(count, 2); + + input1.value = '456'; + await input1.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` + + +
456
+ ` + ); + assert.equal(input1.value, '456'); + assert.equal(input2.value, '456'); + assert.equal(count, 3); + } +}; diff --git a/test/runtime/samples/component-binding-store/main.svelte b/test/runtime/samples/component-binding-store/main.svelte new file mode 100644 index 0000000000..dba08e5276 --- /dev/null +++ b/test/runtime/samples/component-binding-store/main.svelte @@ -0,0 +1,18 @@ + + + + + + +
{$value.value}
\ No newline at end of file diff --git a/test/runtime/samples/component-data-dynamic-shorthand/_config.js b/test/runtime/samples/component-data-dynamic-shorthand/_config.js index 80e8731dc5..779966d4aa 100644 --- a/test/runtime/samples/component-data-dynamic-shorthand/_config.js +++ b/test/runtime/samples/component-data-dynamic-shorthand/_config.js @@ -3,11 +3,11 @@ export default { foo: 42 }, - html: `

foo: 42

`, + html: '

foo: 42

', test({ assert, component, target }) { component.foo = 99; - assert.equal( target.innerHTML, `

foo: 99

` ); + assert.equal( target.innerHTML, '

foo: 99

' ); } }; diff --git a/test/runtime/samples/component-data-empty/_config.js b/test/runtime/samples/component-data-empty/_config.js index eaf16a72af..486827f398 100644 --- a/test/runtime/samples/component-data-empty/_config.js +++ b/test/runtime/samples/component-data-empty/_config.js @@ -1,3 +1,3 @@ export default { - html: `

foo: ''

` + html: "

foo: ''

" }; diff --git a/test/runtime/samples/component-data-static-boolean-regression/_config.js b/test/runtime/samples/component-data-static-boolean-regression/_config.js index 61f8ba0a06..93d0f1165c 100644 --- a/test/runtime/samples/component-data-static-boolean-regression/_config.js +++ b/test/runtime/samples/component-data-static-boolean-regression/_config.js @@ -1,3 +1,3 @@ export default { - html: `link` + html: "link" }; diff --git a/test/runtime/samples/component-data-static-boolean/_config.js b/test/runtime/samples/component-data-static-boolean/_config.js index aaaf3de630..7253644c64 100644 --- a/test/runtime/samples/component-data-static-boolean/_config.js +++ b/test/runtime/samples/component-data-static-boolean/_config.js @@ -1,3 +1,3 @@ export default { - html: `

x: true (boolean)

` + html: '

x: true (boolean)

' }; diff --git a/test/runtime/samples/component-event-handler-contenteditable/_config.js b/test/runtime/samples/component-event-handler-contenteditable/_config.js new file mode 100644 index 0000000000..3a85734975 --- /dev/null +++ b/test/runtime/samples/component-event-handler-contenteditable/_config.js @@ -0,0 +1,15 @@ +export default { + html: ` +
+ `, + + async test({ assert, component, target, window }) { + const div = target.querySelector('div'); + const text = window.document.createTextNode('a'); + div.insertBefore(text, null); + const event = new window.InputEvent('input'); + await div.dispatchEvent(event); + + assert.equal(div.textContent, 'a'); + } +}; diff --git a/test/runtime/samples/component-event-handler-contenteditable/main.svelte b/test/runtime/samples/component-event-handler-contenteditable/main.svelte new file mode 100644 index 0000000000..1eb5911df8 --- /dev/null +++ b/test/runtime/samples/component-event-handler-contenteditable/main.svelte @@ -0,0 +1,6 @@ + + +
{text}
diff --git a/test/runtime/samples/component-event-not-stale/_config.js b/test/runtime/samples/component-event-not-stale/_config.js index 912ea1f7d0..7951afb9d5 100644 --- a/test/runtime/samples/component-event-not-stale/_config.js +++ b/test/runtime/samples/component-event-not-stale/_config.js @@ -1,6 +1,6 @@ export default { props: { - value: 1, + value: 1 }, test({ assert, component, target, window }) { @@ -26,5 +26,5 @@ export default { { value: 2 }, { value: 2 } ]); - }, + } }; diff --git a/test/runtime/samples/component-events-console/_config.js b/test/runtime/samples/component-events-console/_config.js index b800749785..39ccbd719f 100644 --- a/test/runtime/samples/component-events-console/_config.js +++ b/test/runtime/samples/component-events-console/_config.js @@ -21,5 +21,5 @@ export default { } console.log = log; - }, + } }; diff --git a/test/runtime/samples/component-name-deconflicted-globals/_config.js b/test/runtime/samples/component-name-deconflicted-globals/_config.js index 842b6a3a11..66d1d1a8f1 100644 --- a/test/runtime/samples/component-name-deconflicted-globals/_config.js +++ b/test/runtime/samples/component-name-deconflicted-globals/_config.js @@ -2,4 +2,4 @@ export default { preserveIdentifiers: true, error: 'Countdown is not defined' -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/component-name-deconflicted/_config.js b/test/runtime/samples/component-name-deconflicted/_config.js index 97ea2290b6..5813042745 100644 --- a/test/runtime/samples/component-name-deconflicted/_config.js +++ b/test/runtime/samples/component-name-deconflicted/_config.js @@ -12,4 +12,4 @@ export default { 4 `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/component-namespace/Tooltip.svelte b/test/runtime/samples/component-namespace/Tooltip.svelte new file mode 100644 index 0000000000..9b44ef57a8 --- /dev/null +++ b/test/runtime/samples/component-namespace/Tooltip.svelte @@ -0,0 +1 @@ +

i am a widget

\ No newline at end of file diff --git a/test/runtime/samples/component-namespace/Widget.svelte b/test/runtime/samples/component-namespace/Widget.svelte new file mode 100644 index 0000000000..b6aa45c6a8 --- /dev/null +++ b/test/runtime/samples/component-namespace/Widget.svelte @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-namespace/_config.js b/test/runtime/samples/component-namespace/_config.js new file mode 100644 index 0000000000..5b96ac8df0 --- /dev/null +++ b/test/runtime/samples/component-namespace/_config.js @@ -0,0 +1,3 @@ +export default { + html: '

i am a widget

' +}; diff --git a/test/runtime/samples/component-namespace/main.svelte b/test/runtime/samples/component-namespace/main.svelte new file mode 100644 index 0000000000..3f53b2b1c8 --- /dev/null +++ b/test/runtime/samples/component-namespace/main.svelte @@ -0,0 +1,8 @@ + + +{#each widgets as LazyWidget} + +{/each} \ No newline at end of file diff --git a/test/runtime/samples/component-namespaced/_config.js b/test/runtime/samples/component-namespaced/_config.js index b91795d6c8..35a5e46d47 100644 --- a/test/runtime/samples/component-namespaced/_config.js +++ b/test/runtime/samples/component-namespaced/_config.js @@ -19,4 +19,4 @@ export default {

foo 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/component-namespaced/components.js b/test/runtime/samples/component-namespaced/components.js index 832d2412ee..7dcfcf157c 100644 --- a/test/runtime/samples/component-namespaced/components.js +++ b/test/runtime/samples/component-namespaced/components.js @@ -1,3 +1,3 @@ import Foo from './Foo.svelte'; -export default { Foo }; \ No newline at end of file +export default { Foo }; diff --git a/test/runtime/samples/component-shorthand-import/_config.js b/test/runtime/samples/component-shorthand-import/_config.js index ceb8e19f68..dd60415537 100644 --- a/test/runtime/samples/component-shorthand-import/_config.js +++ b/test/runtime/samples/component-shorthand-import/_config.js @@ -1,3 +1,3 @@ export default { - html: `

This is the widget.

`, + html: '

This is the widget.

' }; diff --git a/test/runtime/samples/component-slot-chained/_config.js b/test/runtime/samples/component-slot-chained/_config.js index 6c028f8c31..f2f71df8d6 100644 --- a/test/runtime/samples/component-slot-chained/_config.js +++ b/test/runtime/samples/component-slot-chained/_config.js @@ -3,6 +3,6 @@ export default { test({ assert, component, target }) { component.text = 'two'; - assert.htmlEqual(target.innerHTML, `two`); + assert.htmlEqual(target.innerHTML, 'two'); } }; diff --git a/test/runtime/samples/component-slot-context-props-each-nested/Nested.svelte b/test/runtime/samples/component-slot-context-props-each-nested/Nested.svelte new file mode 100644 index 0000000000..fab3ae1890 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-each-nested/Nested.svelte @@ -0,0 +1,14 @@ + + +{#each items as item (item)} + {#each keys as key (key)} + setKey(key, value, item)} /> + {/each} +{/each} \ No newline at end of file diff --git a/test/runtime/samples/component-slot-context-props-each-nested/_config.js b/test/runtime/samples/component-slot-context-props-each-nested/_config.js new file mode 100644 index 0000000000..869cc555b1 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-each-nested/_config.js @@ -0,0 +1,36 @@ +export default { + html: ` + + + + + `, + async test({ assert, target, window, component }) { + const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); + const click = new window.MouseEvent('click'); + + await btn1.dispatchEvent(click); + assert.deepEqual(component.log, ['setKey(a, value-a-c, c)']); + + await btn2.dispatchEvent(click); + assert.deepEqual(component.log, [ + 'setKey(a, value-a-c, c)', + 'setKey(b, value-b-c, c)' + ]); + + await btn3.dispatchEvent(click); + assert.deepEqual(component.log, [ + 'setKey(a, value-a-c, c)', + 'setKey(b, value-b-c, c)', + 'setKey(a, value-a-d, d)' + ]); + + await btn4.dispatchEvent(click); + assert.deepEqual(component.log, [ + 'setKey(a, value-a-c, c)', + 'setKey(b, value-b-c, c)', + 'setKey(a, value-a-d, d)', + 'setKey(b, value-b-d, d)' + ]); + } +}; diff --git a/test/runtime/samples/component-slot-context-props-each-nested/main.svelte b/test/runtime/samples/component-slot-context-props-each-nested/main.svelte new file mode 100644 index 0000000000..7feb55aaf6 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-each-nested/main.svelte @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-context-props-each/Nested.svelte b/test/runtime/samples/component-slot-context-props-each/Nested.svelte new file mode 100644 index 0000000000..a29ffe0376 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-each/Nested.svelte @@ -0,0 +1,11 @@ + + +{#each keys as key (key)} + setKey(key, value)} /> +{/each} \ No newline at end of file diff --git a/test/runtime/samples/component-slot-context-props-each/_config.js b/test/runtime/samples/component-slot-context-props-each/_config.js new file mode 100644 index 0000000000..f374e7f827 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-each/_config.js @@ -0,0 +1,19 @@ +export default { + html: ` + + + `, + async test({ assert, target, window, component }) { + const [btn1, btn2] = target.querySelectorAll('button'); + const click = new window.MouseEvent('click'); + + await btn1.dispatchEvent(click); + assert.deepEqual(component.log, ['setKey(a, value-a)']); + + await btn2.dispatchEvent(click); + assert.deepEqual(component.log, [ + 'setKey(a, value-a)', + 'setKey(b, value-b)' + ]); + } +}; diff --git a/test/runtime/samples/component-slot-context-props-each/main.svelte b/test/runtime/samples/component-slot-context-props-each/main.svelte new file mode 100644 index 0000000000..7dc17b4c95 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-each/main.svelte @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-context-props-let/Inner.svelte b/test/runtime/samples/component-slot-context-props-let/Inner.svelte new file mode 100644 index 0000000000..6beaabbb68 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-let/Inner.svelte @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-context-props-let/Nested.svelte b/test/runtime/samples/component-slot-context-props-let/Nested.svelte new file mode 100644 index 0000000000..97c44c5145 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-let/Nested.svelte @@ -0,0 +1,8 @@ + + + + set(key, value)} /> + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-context-props-let/_config.js b/test/runtime/samples/component-slot-context-props-let/_config.js new file mode 100644 index 0000000000..f374e7f827 --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-let/_config.js @@ -0,0 +1,19 @@ +export default { + html: ` + + + `, + async test({ assert, target, window, component }) { + const [btn1, btn2] = target.querySelectorAll('button'); + const click = new window.MouseEvent('click'); + + await btn1.dispatchEvent(click); + assert.deepEqual(component.log, ['setKey(a, value-a)']); + + await btn2.dispatchEvent(click); + assert.deepEqual(component.log, [ + 'setKey(a, value-a)', + 'setKey(b, value-b)' + ]); + } +}; diff --git a/test/runtime/samples/component-slot-context-props-let/main.svelte b/test/runtime/samples/component-slot-context-props-let/main.svelte new file mode 100644 index 0000000000..a061f73b3a --- /dev/null +++ b/test/runtime/samples/component-slot-context-props-let/main.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/test/runtime/samples/component-slot-empty-b/_config.js b/test/runtime/samples/component-slot-empty-b/_config.js index 8c1b13b1d5..388e1a3e4a 100644 --- a/test/runtime/samples/component-slot-empty-b/_config.js +++ b/test/runtime/samples/component-slot-empty-b/_config.js @@ -1,3 +1,3 @@ export default { - html: `
` + html: '
' }; diff --git a/test/runtime/samples/component-slot-fallback-2/Inner.svelte b/test/runtime/samples/component-slot-fallback-2/Inner.svelte new file mode 100644 index 0000000000..d1c247ad35 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-2/Inner.svelte @@ -0,0 +1,7 @@ + + + +{value} \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-2/Outer.svelte b/test/runtime/samples/component-slot-fallback-2/Outer.svelte new file mode 100644 index 0000000000..1e44ba4db7 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-2/Outer.svelte @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-2/_config.js b/test/runtime/samples/component-slot-fallback-2/_config.js new file mode 100644 index 0000000000..7c86357a8e --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-2/_config.js @@ -0,0 +1,39 @@ +export default { + html: ' ', + ssrHtml: ' ', + + async test({ assert, target, component, window }) { + const [input1, input2, inputFallback] = target.querySelectorAll('input'); + + assert.equal(component.getSubscriberCount(), 3); + + input1.value = 'a'; + await input1.dispatchEvent(new window.Event('input')); + input1.value = 'ab'; + await input1.dispatchEvent(new window.Event('input')); + assert.equal(input1.value, 'ab'); + assert.equal(input2.value, 'ab'); + assert.equal(inputFallback.value, 'ab'); + + component.props = 'hello'; + + assert.htmlEqual( + target.innerHTML, + ` + hello + hello + + ` + ); + + component.fallback = 'world'; + assert.htmlEqual( + target.innerHTML, + ` + hello + hello + world + ` + ); + } +}; diff --git a/test/runtime/samples/component-slot-fallback-2/main.svelte b/test/runtime/samples/component-slot-fallback-2/main.svelte new file mode 100644 index 0000000000..4583667015 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-2/main.svelte @@ -0,0 +1,23 @@ + + + + + + + + + + + + diff --git a/test/runtime/samples/component-slot-fallback-2/store.svelte b/test/runtime/samples/component-slot-fallback-2/store.svelte new file mode 100644 index 0000000000..e377aaf314 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-2/store.svelte @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-3/Inner.svelte b/test/runtime/samples/component-slot-fallback-3/Inner.svelte new file mode 100644 index 0000000000..db2af272d2 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-3/Inner.svelte @@ -0,0 +1,6 @@ + +
Hello
+
world
+
Bye
+
World
+
diff --git a/test/runtime/samples/component-slot-fallback-3/_config.js b/test/runtime/samples/component-slot-fallback-3/_config.js new file mode 100644 index 0000000000..25cc65eb2d --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-3/_config.js @@ -0,0 +1,6 @@ +export default { + html: ` +
Hello World
+
Hello
world
Bye
World
+ ` +}; diff --git a/test/runtime/samples/component-slot-fallback-3/main.svelte b/test/runtime/samples/component-slot-fallback-3/main.svelte new file mode 100644 index 0000000000..eda7ea60e4 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-3/main.svelte @@ -0,0 +1,9 @@ + + + +
Hello World
+
+ + diff --git a/test/runtime/samples/component-slot-fallback-4/Inner.svelte b/test/runtime/samples/component-slot-fallback-4/Inner.svelte new file mode 100644 index 0000000000..9eb3ef1401 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-4/Inner.svelte @@ -0,0 +1,3 @@ + + + foobar \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-4/_config.js b/test/runtime/samples/component-slot-fallback-4/_config.js new file mode 100644 index 0000000000..4ebe353513 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-4/_config.js @@ -0,0 +1,5 @@ +export default { + html: ` + foobar + ` +}; diff --git a/test/runtime/samples/component-slot-fallback-4/main.svelte b/test/runtime/samples/component-slot-fallback-4/main.svelte new file mode 100644 index 0000000000..206ce21def --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-4/main.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/runtime/samples/component-slot-fallback-5/IconA.svelte b/test/runtime/samples/component-slot-fallback-5/IconA.svelte new file mode 100644 index 0000000000..8921b6c531 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-5/IconA.svelte @@ -0,0 +1 @@ +Icon A \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-5/IconB.svelte b/test/runtime/samples/component-slot-fallback-5/IconB.svelte new file mode 100644 index 0000000000..8a1a95ead3 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-5/IconB.svelte @@ -0,0 +1 @@ +Icon B \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-5/Inner.svelte b/test/runtime/samples/component-slot-fallback-5/Inner.svelte new file mode 100644 index 0000000000..bc4b224c23 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-5/Inner.svelte @@ -0,0 +1,13 @@ + + + +
+ + + +
diff --git a/test/runtime/samples/component-slot-fallback-5/_config.js b/test/runtime/samples/component-slot-fallback-5/_config.js new file mode 100644 index 0000000000..07d09a3be9 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-5/_config.js @@ -0,0 +1,31 @@ +export default { + html: ` + +
Icon B
+ `, + + async test({ assert, target, window }) { + const btn = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +
Icon A
+ ` + ); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +
Icon B
+ ` + ); + } +}; diff --git a/test/runtime/samples/component-slot-fallback-5/main.svelte b/test/runtime/samples/component-slot-fallback-5/main.svelte new file mode 100644 index 0000000000..206ce21def --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-5/main.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/runtime/samples/component-slot-fallback-6/Foo.svelte b/test/runtime/samples/component-slot-fallback-6/Foo.svelte new file mode 100644 index 0000000000..0385342cef --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-6/Foo.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-6/Inner.svelte b/test/runtime/samples/component-slot-fallback-6/Inner.svelte new file mode 100644 index 0000000000..28f0fdd869 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-6/Inner.svelte @@ -0,0 +1,9 @@ + + + + + {JSON.stringify($$props)} + + diff --git a/test/runtime/samples/component-slot-fallback-6/_config.js b/test/runtime/samples/component-slot-fallback-6/_config.js new file mode 100644 index 0000000000..b32d96db2e --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-6/_config.js @@ -0,0 +1,18 @@ +// $$props reactivity in slot fallback +export default { + html: ` + + {"value":""} + `, + + async test({ assert, target, window }) { + const input = target.querySelector('input'); + input.value = 'abc'; + await input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual(target.innerHTML, ` + + {"value":"abc"} + `); + } +}; diff --git a/test/runtime/samples/component-slot-fallback-6/main.svelte b/test/runtime/samples/component-slot-fallback-6/main.svelte new file mode 100644 index 0000000000..35abebef10 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-6/main.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/test/runtime/samples/component-slot-let-in-slot/_config.js b/test/runtime/samples/component-slot-let-in-slot/_config.js index a86d869581..eb16c27fda 100644 --- a/test/runtime/samples/component-slot-let-in-slot/_config.js +++ b/test/runtime/samples/component-slot-let-in-slot/_config.js @@ -1,6 +1,6 @@ export default { props: { - prop: 'a', + prop: 'a' }, html: 'a', diff --git a/test/runtime/samples/component-slot-let-static/_config.js b/test/runtime/samples/component-slot-let-static/_config.js index 3067939b88..ede7a679c5 100644 --- a/test/runtime/samples/component-slot-let-static/_config.js +++ b/test/runtime/samples/component-slot-let-static/_config.js @@ -1,3 +1,3 @@ export default { - html: `

Hi

` + html: '

Hi

' }; diff --git a/test/runtime/samples/component-slot-named-inherits-default-lets/_config.js b/test/runtime/samples/component-slot-named-inherits-default-lets/_config.js index a07a1482bc..8297162b91 100644 --- a/test/runtime/samples/component-slot-named-inherits-default-lets/_config.js +++ b/test/runtime/samples/component-slot-named-inherits-default-lets/_config.js @@ -22,4 +22,4 @@ export default {
`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/component-slot-nested-error-2/Nested.svelte b/test/runtime/samples/component-slot-nested-error-2/Nested.svelte new file mode 100644 index 0000000000..c6f086d96c --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error-2/Nested.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-nested-error-2/_config.js b/test/runtime/samples/component-slot-nested-error-2/_config.js new file mode 100644 index 0000000000..08c436b16d --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error-2/_config.js @@ -0,0 +1,3 @@ +export default { + error: ["Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"] +}; diff --git a/test/runtime/samples/component-slot-nested-error-2/main.svelte b/test/runtime/samples/component-slot-nested-error-2/main.svelte new file mode 100644 index 0000000000..a7142d6dc1 --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error-2/main.svelte @@ -0,0 +1,11 @@ + + + +
+
+
+
+
+ diff --git a/test/runtime/samples/component-slot-nested-error-3/Nested.svelte b/test/runtime/samples/component-slot-nested-error-3/Nested.svelte new file mode 100644 index 0000000000..c6f086d96c --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error-3/Nested.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-nested-error-3/_config.js b/test/runtime/samples/component-slot-nested-error-3/_config.js new file mode 100644 index 0000000000..08c436b16d --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error-3/_config.js @@ -0,0 +1,3 @@ +export default { + error: ["Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"] +}; diff --git a/test/runtime/samples/component-slot-nested-error-3/main.svelte b/test/runtime/samples/component-slot-nested-error-3/main.svelte new file mode 100644 index 0000000000..a63b1defde --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error-3/main.svelte @@ -0,0 +1,11 @@ + + + +
+
+
+
+
+ diff --git a/test/runtime/samples/component-slot-nested-error/Nested.svelte b/test/runtime/samples/component-slot-nested-error/Nested.svelte new file mode 100644 index 0000000000..c6f086d96c --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error/Nested.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-nested-error/_config.js b/test/runtime/samples/component-slot-nested-error/_config.js new file mode 100644 index 0000000000..08c436b16d --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error/_config.js @@ -0,0 +1,3 @@ +export default { + error: ["Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"] +}; diff --git a/test/runtime/samples/component-slot-nested-error/main.svelte b/test/runtime/samples/component-slot-nested-error/main.svelte new file mode 100644 index 0000000000..531c96f08c --- /dev/null +++ b/test/runtime/samples/component-slot-nested-error/main.svelte @@ -0,0 +1,9 @@ + + + +
+
+
+ diff --git a/test/runtime/samples/component-slot-nested-if/_config.js b/test/runtime/samples/component-slot-nested-if/_config.js index 89dfd006cc..45c570fc22 100644 --- a/test/runtime/samples/component-slot-nested-if/_config.js +++ b/test/runtime/samples/component-slot-nested-if/_config.js @@ -26,5 +26,5 @@ export default { Display: abc ` ); - }, + } }; diff --git a/test/runtime/samples/component-slot-nested-in-slot/One.svelte b/test/runtime/samples/component-slot-nested-in-slot/One.svelte new file mode 100644 index 0000000000..e27437c450 --- /dev/null +++ b/test/runtime/samples/component-slot-nested-in-slot/One.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/test/runtime/samples/component-slot-nested-in-slot/Two.svelte b/test/runtime/samples/component-slot-nested-in-slot/Two.svelte new file mode 100644 index 0000000000..3f21e2d16f --- /dev/null +++ b/test/runtime/samples/component-slot-nested-in-slot/Two.svelte @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-nested-in-slot/_config.js b/test/runtime/samples/component-slot-nested-in-slot/_config.js new file mode 100644 index 0000000000..56a9ef2668 --- /dev/null +++ b/test/runtime/samples/component-slot-nested-in-slot/_config.js @@ -0,0 +1,18 @@ +export default { + html: ` +

one: 1 two: 2

+ `, + test({ assert, component, target }) { + component.a = 3; + component.b = 4; + assert.htmlEqual(target.innerHTML, ` +

one: 3 two: 4

+ `); + + component.a = 5; + component.b = 6; + assert.htmlEqual(target.innerHTML, ` +

one: 5 two: 6

+ `); + } +}; diff --git a/test/runtime/samples/component-slot-nested-in-slot/main.svelte b/test/runtime/samples/component-slot-nested-in-slot/main.svelte new file mode 100644 index 0000000000..38a172e668 --- /dev/null +++ b/test/runtime/samples/component-slot-nested-in-slot/main.svelte @@ -0,0 +1,9 @@ + + + +

one: {one} two: {two}

+
\ No newline at end of file diff --git a/test/runtime/samples/component-slot-slot/Component.svelte b/test/runtime/samples/component-slot-slot/Component.svelte new file mode 100644 index 0000000000..fdcb8e7f2b --- /dev/null +++ b/test/runtime/samples/component-slot-slot/Component.svelte @@ -0,0 +1,3 @@ +
+ +
diff --git a/test/runtime/samples/component-slot-slot/Forward.svelte b/test/runtime/samples/component-slot-slot/Forward.svelte new file mode 100644 index 0000000000..320be9df25 --- /dev/null +++ b/test/runtime/samples/component-slot-slot/Forward.svelte @@ -0,0 +1,7 @@ + + + + + diff --git a/test/runtime/samples/component-slot-slot/_config.js b/test/runtime/samples/component-slot-slot/_config.js new file mode 100644 index 0000000000..32af774fac --- /dev/null +++ b/test/runtime/samples/component-slot-slot/_config.js @@ -0,0 +1,3 @@ +export default { + html: '
lol
' +}; diff --git a/test/runtime/samples/component-slot-slot/main.svelte b/test/runtime/samples/component-slot-slot/main.svelte new file mode 100644 index 0000000000..1718494b16 --- /dev/null +++ b/test/runtime/samples/component-slot-slot/main.svelte @@ -0,0 +1,9 @@ + + + + + lol + + diff --git a/test/runtime/samples/component-static-at-symbol/_config.js b/test/runtime/samples/component-static-at-symbol/_config.js index a2f60e3de7..0be19f091f 100644 --- a/test/runtime/samples/component-static-at-symbol/_config.js +++ b/test/runtime/samples/component-static-at-symbol/_config.js @@ -1,3 +1,3 @@ export default { - html: `email` + html: "email" }; diff --git a/test/runtime/samples/component-yield-multiple-in-if/_config.js b/test/runtime/samples/component-yield-multiple-in-if/_config.js index d5d630a84d..7263cc55aa 100644 --- a/test/runtime/samples/component-yield-multiple-in-if/_config.js +++ b/test/runtime/samples/component-yield-multiple-in-if/_config.js @@ -5,6 +5,6 @@ export default { test({ assert, component, target }) { component.arriving = false; - assert.htmlEqual(target.innerHTML, `

Goodbye

`); + assert.htmlEqual(target.innerHTML, "

Goodbye

"); } }; diff --git a/test/runtime/samples/component-yield-nested-if/_config.js b/test/runtime/samples/component-yield-nested-if/_config.js index f16a7bb6bf..b46996cea3 100644 --- a/test/runtime/samples/component-yield-nested-if/_config.js +++ b/test/runtime/samples/component-yield-nested-if/_config.js @@ -6,9 +6,9 @@ export default { test({ assert, component, target }) { component.foo = false; - assert.htmlEqual( target.innerHTML, `` ); + assert.htmlEqual( target.innerHTML, '' ); component.foo = true; - assert.htmlEqual( target.innerHTML, `One\nInner` ); + assert.htmlEqual( target.innerHTML, 'One\nInner' ); } }; diff --git a/test/runtime/samples/context-api-b/_config.js b/test/runtime/samples/context-api-b/_config.js index 70dff54c06..314fd9f481 100644 --- a/test/runtime/samples/context-api-b/_config.js +++ b/test/runtime/samples/context-api-b/_config.js @@ -3,4 +3,4 @@ export default {
foo/bar
foo/baz
` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/context-api/_config.js b/test/runtime/samples/context-api/_config.js index 1bc475a156..3856aa5424 100644 --- a/test/runtime/samples/context-api/_config.js +++ b/test/runtime/samples/context-api/_config.js @@ -70,4 +70,4 @@ export default {
`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/context-in-await/_config.js b/test/runtime/samples/context-in-await/_config.js index 221f5fbcca..fc498a36c2 100644 --- a/test/runtime/samples/context-in-await/_config.js +++ b/test/runtime/samples/context-in-await/_config.js @@ -10,4 +10,4 @@ export default {

Context value: 123

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/contextual-callback/_config.js b/test/runtime/samples/contextual-callback/_config.js index d47d9d001e..b27a7fc868 100644 --- a/test/runtime/samples/contextual-callback/_config.js +++ b/test/runtime/samples/contextual-callback/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', async test({ assert, component, target, window }) { const button = target.querySelector('button'); @@ -9,4 +9,4 @@ export default { assert.equal(component.clicked, 'x'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-anchor/Anchor.svelte b/test/runtime/samples/deconflict-anchor/Anchor.svelte new file mode 100644 index 0000000000..e758d60056 --- /dev/null +++ b/test/runtime/samples/deconflict-anchor/Anchor.svelte @@ -0,0 +1 @@ +

Anchor

diff --git a/test/runtime/samples/deconflict-anchor/_config.js b/test/runtime/samples/deconflict-anchor/_config.js new file mode 100644 index 0000000000..323cb7530a --- /dev/null +++ b/test/runtime/samples/deconflict-anchor/_config.js @@ -0,0 +1,4 @@ +export default { + preserveIdentifiers: true, + html: '

Anchor

' +}; diff --git a/test/runtime/samples/deconflict-anchor/main.svelte b/test/runtime/samples/deconflict-anchor/main.svelte new file mode 100644 index 0000000000..cce6281e49 --- /dev/null +++ b/test/runtime/samples/deconflict-anchor/main.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/runtime/samples/deconflict-block-methods/_config.js b/test/runtime/samples/deconflict-block-methods/_config.js index 2bb1aa8424..07c699df4d 100644 --- a/test/runtime/samples/deconflict-block-methods/_config.js +++ b/test/runtime/samples/deconflict-block-methods/_config.js @@ -2,5 +2,5 @@ export default { compileOptions: { dev: true }, - html: `
deconflicted
` + html: '
deconflicted
' }; diff --git a/test/runtime/samples/deconflict-builtins-2/_config.js b/test/runtime/samples/deconflict-builtins-2/_config.js index 5870ff073b..e136b0410d 100644 --- a/test/runtime/samples/deconflict-builtins-2/_config.js +++ b/test/runtime/samples/deconflict-builtins-2/_config.js @@ -1,4 +1,4 @@ export default { - html: `hello world`, - preserveIdentifiers: true, -}; \ No newline at end of file + html: 'hello world', + preserveIdentifiers: true +}; diff --git a/test/runtime/samples/deconflict-builtins/_config.js b/test/runtime/samples/deconflict-builtins/_config.js index c7053194ee..3751bfc25d 100644 --- a/test/runtime/samples/deconflict-builtins/_config.js +++ b/test/runtime/samples/deconflict-builtins/_config.js @@ -1,7 +1,7 @@ export default { - html: `got`, + html: 'got', test({ assert, component }) { assert.equal(component.foo, 'got'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-builtins/get.js b/test/runtime/samples/deconflict-builtins/get.js index cd846d9be9..78477cc40f 100644 --- a/test/runtime/samples/deconflict-builtins/get.js +++ b/test/runtime/samples/deconflict-builtins/get.js @@ -1,3 +1,3 @@ export function get () { return 'got'; -} \ No newline at end of file +} diff --git a/test/runtime/samples/deconflict-component-name-with-global/_config.js b/test/runtime/samples/deconflict-component-name-with-global/_config.js index 4b8255868e..214483fc58 100644 --- a/test/runtime/samples/deconflict-component-name-with-global/_config.js +++ b/test/runtime/samples/deconflict-component-name-with-global/_config.js @@ -5,5 +5,5 @@ export default { preserveIdentifiers: true, - html: `

true

` -}; \ No newline at end of file + html: '

true

' +}; diff --git a/test/runtime/samples/deconflict-component-name-with-module-global/_config.js b/test/runtime/samples/deconflict-component-name-with-module-global/_config.js index 4b8255868e..214483fc58 100644 --- a/test/runtime/samples/deconflict-component-name-with-module-global/_config.js +++ b/test/runtime/samples/deconflict-component-name-with-module-global/_config.js @@ -5,5 +5,5 @@ export default { preserveIdentifiers: true, - html: `

true

` -}; \ No newline at end of file + html: '

true

' +}; diff --git a/test/runtime/samples/deconflict-component-refs/_config.js b/test/runtime/samples/deconflict-component-refs/_config.js index 8092aed7ca..992066d1e6 100644 --- a/test/runtime/samples/deconflict-component-refs/_config.js +++ b/test/runtime/samples/deconflict-component-refs/_config.js @@ -22,4 +22,4 @@ export default { { name: 'baz', edit: false } ] } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-contexts/_config.js b/test/runtime/samples/deconflict-contexts/_config.js index a32300e58a..5254655d89 100644 --- a/test/runtime/samples/deconflict-contexts/_config.js +++ b/test/runtime/samples/deconflict-contexts/_config.js @@ -6,4 +6,4 @@ export default { props: { components: [ 'foo', 'bar', 'baz' ] } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-ctx/_config.js b/test/runtime/samples/deconflict-ctx/_config.js index 88f3e2efca..b6d8bf51be 100644 --- a/test/runtime/samples/deconflict-ctx/_config.js +++ b/test/runtime/samples/deconflict-ctx/_config.js @@ -2,4 +2,4 @@ export default { html: `

Hello world!

` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-elements-indexes/_config.js b/test/runtime/samples/deconflict-elements-indexes/_config.js index b531603ac7..cb102638f2 100644 --- a/test/runtime/samples/deconflict-elements-indexes/_config.js +++ b/test/runtime/samples/deconflict-elements-indexes/_config.js @@ -19,4 +19,4 @@ export default {
`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-non-helpers/_config.js b/test/runtime/samples/deconflict-non-helpers/_config.js index 167ddc279c..8bbdc872e5 100644 --- a/test/runtime/samples/deconflict-non-helpers/_config.js +++ b/test/runtime/samples/deconflict-non-helpers/_config.js @@ -1,5 +1,5 @@ export default { - html: `ABCD`, + html: 'ABCD', test({ assert, component }) { assert.equal(component.compute(), 'ABCD'); diff --git a/test/runtime/samples/deconflict-self/_config.js b/test/runtime/samples/deconflict-self/_config.js index 86341e7379..44bea34e09 100644 --- a/test/runtime/samples/deconflict-self/_config.js +++ b/test/runtime/samples/deconflict-self/_config.js @@ -1,3 +1,3 @@ export default { - html: `

nested component

` + html: '

nested component

' }; diff --git a/test/runtime/samples/deconflict-spread-i/_config.js b/test/runtime/samples/deconflict-spread-i/_config.js index f147a4c1ff..7602cde023 100644 --- a/test/runtime/samples/deconflict-spread-i/_config.js +++ b/test/runtime/samples/deconflict-spread-i/_config.js @@ -1,3 +1,3 @@ export default { preserveIdentifiers: true -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/deconflict-template-1/_config.js b/test/runtime/samples/deconflict-template-1/_config.js index c7ca7bec26..faddb5b6fd 100644 --- a/test/runtime/samples/deconflict-template-1/_config.js +++ b/test/runtime/samples/deconflict-template-1/_config.js @@ -1,3 +1,3 @@ export default { - html: `template` + html: 'template' }; diff --git a/test/runtime/samples/deconflict-template-2/_config.js b/test/runtime/samples/deconflict-template-2/_config.js index c7ca7bec26..faddb5b6fd 100644 --- a/test/runtime/samples/deconflict-template-2/_config.js +++ b/test/runtime/samples/deconflict-template-2/_config.js @@ -1,3 +1,3 @@ export default { - html: `template` + html: 'template' }; diff --git a/test/runtime/samples/deconflict-vars/_config.js b/test/runtime/samples/deconflict-vars/_config.js index b3303b13fe..e66ce0f141 100644 --- a/test/runtime/samples/deconflict-vars/_config.js +++ b/test/runtime/samples/deconflict-vars/_config.js @@ -1,3 +1,3 @@ export default { - html: `

ab

` + html: '

ab

' }; diff --git a/test/runtime/samples/destroy-twice/_config.js b/test/runtime/samples/destroy-twice/_config.js index 041518d284..1279b2315d 100644 --- a/test/runtime/samples/destroy-twice/_config.js +++ b/test/runtime/samples/destroy-twice/_config.js @@ -3,4 +3,4 @@ export default { component.$destroy(); component.$destroy(); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/destructuring-assignment-array/_config.js b/test/runtime/samples/destructuring-assignment-array/_config.js index ede4552803..5b39a0b86e 100644 --- a/test/runtime/samples/destructuring-assignment-array/_config.js +++ b/test/runtime/samples/destructuring-assignment-array/_config.js @@ -20,4 +20,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/destructuring-between-exports/_config.js b/test/runtime/samples/destructuring-between-exports/_config.js index 56061f510f..3b2ee6e9ee 100644 --- a/test/runtime/samples/destructuring-between-exports/_config.js +++ b/test/runtime/samples/destructuring-between-exports/_config.js @@ -5,4 +5,4 @@ export default { html: `

42

` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/destructuring/_config.js b/test/runtime/samples/destructuring/_config.js index b8b138dfd0..93e4ed3936 100644 --- a/test/runtime/samples/destructuring/_config.js +++ b/test/runtime/samples/destructuring/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', props: { foo: 42 @@ -22,4 +22,4 @@ export default { assert.equal(count, 1); assert.equal(number, 42); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dev-warning-destroy-twice/_config.js b/test/runtime/samples/dev-warning-destroy-twice/_config.js index 3acbd6447a..69ef5b1713 100644 --- a/test/runtime/samples/dev-warning-destroy-twice/_config.js +++ b/test/runtime/samples/dev-warning-destroy-twice/_config.js @@ -15,9 +15,9 @@ export default { component.$destroy(); assert.deepEqual(warnings, [ - `Component was already destroyed` + 'Component was already destroyed' ]); console.warn = warn; // eslint-disable-line no-console } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dev-warning-each-block-no-sets-maps/_config.js b/test/runtime/samples/dev-warning-each-block-no-sets-maps/_config.js index 83481d9ebe..036130c4e0 100644 --- a/test/runtime/samples/dev-warning-each-block-no-sets-maps/_config.js +++ b/test/runtime/samples/dev-warning-each-block-no-sets-maps/_config.js @@ -2,5 +2,5 @@ export default { compileOptions: { dev: true }, - error: `{#each} only iterates over array-like objects. You can use a spread to convert this iterable into an array.` + error: '{#each} only iterates over array-like objects. You can use a spread to convert this iterable into an array.' }; diff --git a/test/runtime/samples/dev-warning-each-block-require-arraylike/_config.js b/test/runtime/samples/dev-warning-each-block-require-arraylike/_config.js index 62e5fc209b..ff6ef80607 100644 --- a/test/runtime/samples/dev-warning-each-block-require-arraylike/_config.js +++ b/test/runtime/samples/dev-warning-each-block-require-arraylike/_config.js @@ -2,5 +2,5 @@ export default { compileOptions: { dev: true }, - error: `{#each} only iterates over array-like objects.` + error: '{#each} only iterates over array-like objects.' }; diff --git a/test/runtime/samples/dev-warning-missing-data-binding/_config.js b/test/runtime/samples/dev-warning-missing-data-binding/_config.js index f23c5d5ec5..1ba0dfc8ff 100644 --- a/test/runtime/samples/dev-warning-missing-data-binding/_config.js +++ b/test/runtime/samples/dev-warning-missing-data-binding/_config.js @@ -4,6 +4,6 @@ export default { }, warnings: [ - `
was created without expected prop 'value'` + "
was created without expected prop 'value'" ] }; diff --git a/test/runtime/samples/dev-warning-missing-data-component/_config.js b/test/runtime/samples/dev-warning-missing-data-component/_config.js index a95e570988..ececa00a8c 100644 --- a/test/runtime/samples/dev-warning-missing-data-component/_config.js +++ b/test/runtime/samples/dev-warning-missing-data-component/_config.js @@ -4,6 +4,6 @@ export default { }, warnings: [ - ` was created without expected prop 'y'` + " was created without expected prop 'y'" ] }; diff --git a/test/runtime/samples/dev-warning-missing-data-each/_config.js b/test/runtime/samples/dev-warning-missing-data-each/_config.js index 92cda48fce..7d7794eff4 100644 --- a/test/runtime/samples/dev-warning-missing-data-each/_config.js +++ b/test/runtime/samples/dev-warning-missing-data-each/_config.js @@ -7,18 +7,18 @@ export default { letters: [ { id: 1, - char: 'a', + char: 'a' }, { id: 2, - char: 'b', + char: 'b' }, { id: 3, - char: 'c', - }, - ], + char: 'c' + } + ] }, - warnings: [], + warnings: [] }; diff --git a/test/runtime/samples/dev-warning-missing-data/_config.js b/test/runtime/samples/dev-warning-missing-data/_config.js index b929ff4741..f489491ac9 100644 --- a/test/runtime/samples/dev-warning-missing-data/_config.js +++ b/test/runtime/samples/dev-warning-missing-data/_config.js @@ -4,7 +4,7 @@ export default { }, warnings: [ - `
was created without expected prop 'foo'`, - `
was created without expected prop 'bar'` + "
was created without expected prop 'foo'", + "
was created without expected prop 'bar'" ] }; diff --git a/test/runtime/samples/dev-warning-readonly-computed/_config.js b/test/runtime/samples/dev-warning-readonly-computed/_config.js index 33339071f4..86037d7e1f 100644 --- a/test/runtime/samples/dev-warning-readonly-computed/_config.js +++ b/test/runtime/samples/dev-warning-readonly-computed/_config.js @@ -12,7 +12,7 @@ export default { component.foo = 1; throw new Error( 'Expected an error' ); } catch ( err ) { - assert.equal( err.message, `
: Cannot set read-only property 'foo'` ); + assert.equal( err.message, "
: Cannot set read-only property 'foo'" ); } } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dev-warning-readonly-window-binding/_config.js b/test/runtime/samples/dev-warning-readonly-window-binding/_config.js index e0b46584e4..fc6075aef1 100644 --- a/test/runtime/samples/dev-warning-readonly-window-binding/_config.js +++ b/test/runtime/samples/dev-warning-readonly-window-binding/_config.js @@ -8,7 +8,7 @@ export default { component.width = 99; throw new Error('Expected an error'); } catch (err) { - assert.equal(err.message, `
: Cannot set read-only property 'width'`); + assert.equal(err.message, "
: Cannot set read-only property 'width'"); } } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dev-warning-unknown-props-2/_config.js b/test/runtime/samples/dev-warning-unknown-props-2/_config.js index 9bff4a2a74..b28724d719 100644 --- a/test/runtime/samples/dev-warning-unknown-props-2/_config.js +++ b/test/runtime/samples/dev-warning-unknown-props-2/_config.js @@ -4,6 +4,6 @@ export default { }, warnings: [ - ` was created with unknown prop 'fo'` + " was created with unknown prop 'fo'" ] }; diff --git a/test/runtime/samples/dev-warning-unknown-props/_config.js b/test/runtime/samples/dev-warning-unknown-props/_config.js index 9bff4a2a74..b28724d719 100644 --- a/test/runtime/samples/dev-warning-unknown-props/_config.js +++ b/test/runtime/samples/dev-warning-unknown-props/_config.js @@ -4,6 +4,6 @@ export default { }, warnings: [ - ` was created with unknown prop 'fo'` + " was created with unknown prop 'fo'" ] }; diff --git a/test/runtime/samples/document-event/_config.js b/test/runtime/samples/document-event/_config.js index f5e4b46f4f..d9a8866275 100644 --- a/test/runtime/samples/document-event/_config.js +++ b/test/runtime/samples/document-event/_config.js @@ -9,5 +9,5 @@ export default { const event2 = new window.Event('mouseleave'); window.document.body.dispatchEvent(event2); assert.deepEqual(component.events, ['enter', 'leave']); - }, + } }; diff --git a/test/runtime/samples/dynamic-component-bindings-recreated-b/_config.js b/test/runtime/samples/dynamic-component-bindings-recreated-b/_config.js index 0df87f06cd..2f73514e67 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated-b/_config.js +++ b/test/runtime/samples/dynamic-component-bindings-recreated-b/_config.js @@ -25,4 +25,4 @@ export default {

green green

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/_config.js b/test/runtime/samples/dynamic-component-bindings-recreated/_config.js index b57c49ed58..7882996a8b 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/_config.js +++ b/test/runtime/samples/dynamic-component-bindings-recreated/_config.js @@ -22,4 +22,4 @@ export default {

green two

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-bindings/_config.js b/test/runtime/samples/dynamic-component-bindings/_config.js index 9ef9a87b91..4b76c89237 100644 --- a/test/runtime/samples/dynamic-component-bindings/_config.js +++ b/test/runtime/samples/dynamic-component-bindings/_config.js @@ -28,4 +28,4 @@ export default { assert.equal(component.z, true); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-destroy-null/_config.js b/test/runtime/samples/dynamic-component-destroy-null/_config.js index 3c47aa5bae..00f7d47d0f 100644 --- a/test/runtime/samples/dynamic-component-destroy-null/_config.js +++ b/test/runtime/samples/dynamic-component-destroy-null/_config.js @@ -6,4 +6,4 @@ export default { test({ assert, component }) { component.x = false; } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-events/_config.js b/test/runtime/samples/dynamic-component-events/_config.js index 3c6bf370bb..cc54bef4e5 100644 --- a/test/runtime/samples/dynamic-component-events/_config.js +++ b/test/runtime/samples/dynamic-component-events/_config.js @@ -22,4 +22,4 @@ export default { target.querySelector('button').dispatchEvent(click); assert.equal(component.selected, 'bar'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-in-if/_config.js b/test/runtime/samples/dynamic-component-in-if/_config.js index b481c229c4..0c6829dbcd 100644 --- a/test/runtime/samples/dynamic-component-in-if/_config.js +++ b/test/runtime/samples/dynamic-component-in-if/_config.js @@ -10,4 +10,4 @@ export default {

Bar

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-inside-element/_config.js b/test/runtime/samples/dynamic-component-inside-element/_config.js index 2e363f10da..ba144c96a6 100644 --- a/test/runtime/samples/dynamic-component-inside-element/_config.js +++ b/test/runtime/samples/dynamic-component-inside-element/_config.js @@ -14,4 +14,4 @@ export default {

false, therefore Bar

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-nulled-out-intro/_config.js b/test/runtime/samples/dynamic-component-nulled-out-intro/_config.js index 9759ada538..18ccd5f21e 100644 --- a/test/runtime/samples/dynamic-component-nulled-out-intro/_config.js +++ b/test/runtime/samples/dynamic-component-nulled-out-intro/_config.js @@ -2,4 +2,4 @@ export default { test({ component }) { component.visible = true; } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-nulled-out/_config.js b/test/runtime/samples/dynamic-component-nulled-out/_config.js index e6ff6032bf..7e928aba86 100644 --- a/test/runtime/samples/dynamic-component-nulled-out/_config.js +++ b/test/runtime/samples/dynamic-component-nulled-out/_config.js @@ -8,7 +8,7 @@ export default { component.Bar = null; - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); component.Bar = Bar; @@ -16,4 +16,4 @@ export default {

Foo

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-ref/_config.js b/test/runtime/samples/dynamic-component-ref/_config.js index 6e3cabc435..f64a7fd195 100644 --- a/test/runtime/samples/dynamic-component-ref/_config.js +++ b/test/runtime/samples/dynamic-component-ref/_config.js @@ -1,5 +1,5 @@ export default { - html: `Foo`, + html: 'Foo', test({ assert, component }) { assert.ok(component.test); diff --git a/test/runtime/samples/dynamic-component-slot/_config.js b/test/runtime/samples/dynamic-component-slot/_config.js index 58f413e3c4..aedf8bbb5b 100644 --- a/test/runtime/samples/dynamic-component-slot/_config.js +++ b/test/runtime/samples/dynamic-component-slot/_config.js @@ -32,4 +32,4 @@ export default {
what goes up must come down
`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component-update-existing-instance/_config.js b/test/runtime/samples/dynamic-component-update-existing-instance/_config.js index 5e3d836382..adca76f5a7 100644 --- a/test/runtime/samples/dynamic-component-update-existing-instance/_config.js +++ b/test/runtime/samples/dynamic-component-update-existing-instance/_config.js @@ -14,4 +14,4 @@ export default {

Foo 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/dynamic-component/_config.js b/test/runtime/samples/dynamic-component/_config.js index fe7ce5d65f..64abb9bd96 100644 --- a/test/runtime/samples/dynamic-component/_config.js +++ b/test/runtime/samples/dynamic-component/_config.js @@ -14,4 +14,4 @@ export default {

false, therefore Bar

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/each-block-array-literal/_config.js b/test/runtime/samples/each-block-array-literal/_config.js index 288d1cd09f..164e4730bc 100644 --- a/test/runtime/samples/each-block-array-literal/_config.js +++ b/test/runtime/samples/each-block-array-literal/_config.js @@ -15,5 +15,5 @@ export default { button.dispatchEvent(event); assert.equal(component.clicked, 'racoon'); - }, + } }; diff --git a/test/runtime/samples/each-block-component-no-props/_config.js b/test/runtime/samples/each-block-component-no-props/_config.js index e8344496ca..329da68324 100644 --- a/test/runtime/samples/each-block-component-no-props/_config.js +++ b/test/runtime/samples/each-block-component-no-props/_config.js @@ -5,12 +5,12 @@ export default { async test({ assert, component, target }) { await component.remove(); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); await component.add(); - assert.htmlEqual(target.innerHTML, `

hello

`); + assert.htmlEqual(target.innerHTML, '

hello

'); await component.remove(); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); } }; diff --git a/test/runtime/samples/each-block-containing-component-in-if/_config.js b/test/runtime/samples/each-block-containing-component-in-if/_config.js index 9083742891..d617d23cd3 100644 --- a/test/runtime/samples/each-block-containing-component-in-if/_config.js +++ b/test/runtime/samples/each-block-containing-component-in-if/_config.js @@ -4,7 +4,7 @@ export default { fields: [1, 2] }, - html: `
`, + html: '
', test({ assert, component, target }) { component.show = true; diff --git a/test/runtime/samples/each-block-destructured-array-sparse/_config.js b/test/runtime/samples/each-block-destructured-array-sparse/_config.js index 9805276600..331c3aec1b 100644 --- a/test/runtime/samples/each-block-destructured-array-sparse/_config.js +++ b/test/runtime/samples/each-block-destructured-array-sparse/_config.js @@ -16,5 +16,5 @@ export default { assert.htmlEqual( target.innerHTML, `

bar

`); - }, + } }; diff --git a/test/runtime/samples/each-block-destructured-array/_config.js b/test/runtime/samples/each-block-destructured-array/_config.js index 432d8a3a78..e2924c8656 100644 --- a/test/runtime/samples/each-block-destructured-array/_config.js +++ b/test/runtime/samples/each-block-destructured-array/_config.js @@ -16,5 +16,5 @@ export default { assert.htmlEqual( target.innerHTML, `

foo: bar

`); - }, + } }; diff --git a/test/runtime/samples/each-block-destructured-default/_config.js b/test/runtime/samples/each-block-destructured-default/_config.js new file mode 100644 index 0000000000..0e99fd589f --- /dev/null +++ b/test/runtime/samples/each-block-destructured-default/_config.js @@ -0,0 +1,22 @@ +export default { + props: { + animalEntries: [ + { animal: 'raccoon', class: 'mammal', species: 'P. lotor', kilogram: 25 }, + { animal: 'eagle', class: 'bird', kilogram: 5.4 } + ] + }, + + html: ` +

raccoon - P. lotor - 25kg

+

eagle - unknown - 5.4kg

+ `, + + + + test({ assert, component, target }) { + component.animalEntries = [{ animal: 'cow', class: 'mammal', species: '‎B. taurus' }]; + assert.htmlEqual(target.innerHTML, ` +

cow - ‎B. taurus - 50kg

+ `); + } +}; diff --git a/test/runtime/samples/each-block-destructured-default/main.svelte b/test/runtime/samples/each-block-destructured-default/main.svelte new file mode 100644 index 0000000000..a91b45299e --- /dev/null +++ b/test/runtime/samples/each-block-destructured-default/main.svelte @@ -0,0 +1,7 @@ + + +{#each animalEntries as { animal, species = 'unknown', kilogram: weight = 50 , ...props } } +

{animal} - {species} - {weight}kg

+{/each} diff --git a/test/runtime/samples/each-block-destructured-object-binding/_config.js b/test/runtime/samples/each-block-destructured-object-binding/_config.js index 8b59a97034..2ab3e24397 100644 --- a/test/runtime/samples/each-block-destructured-object-binding/_config.js +++ b/test/runtime/samples/each-block-destructured-object-binding/_config.js @@ -1,6 +1,6 @@ export default { props: { - people: [{ name: { first: 'Doctor', last: 'Who' } }], + people: [{ name: { first: 'Doctor', last: 'Who' } }] }, html: ` @@ -41,5 +41,5 @@ export default {

Frank Oz

`); - }, + } }; diff --git a/test/runtime/samples/each-block-destructured-object-rest/_config.js b/test/runtime/samples/each-block-destructured-object-rest/_config.js index 561d4e8442..be5d38b555 100644 --- a/test/runtime/samples/each-block-destructured-object-rest/_config.js +++ b/test/runtime/samples/each-block-destructured-object-rest/_config.js @@ -16,5 +16,5 @@ export default { assert.htmlEqual(target.innerHTML, `

cow

`); - }, + } }; diff --git a/test/runtime/samples/each-block-destructured-object/_config.js b/test/runtime/samples/each-block-destructured-object/_config.js index dc3943fffe..feec72f402 100644 --- a/test/runtime/samples/each-block-destructured-object/_config.js +++ b/test/runtime/samples/each-block-destructured-object/_config.js @@ -16,5 +16,5 @@ export default { assert.htmlEqual( target.innerHTML, `

cow: hooves

`); - }, + } }; diff --git a/test/runtime/samples/each-block-else-in-if/_config.js b/test/runtime/samples/each-block-else-in-if/_config.js index c800ee8a30..24d1e5477a 100644 --- a/test/runtime/samples/each-block-else-in-if/_config.js +++ b/test/runtime/samples/each-block-else-in-if/_config.js @@ -6,7 +6,7 @@ export default { test({ assert, component, target }) { component.visible = false; - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); component.visible = true; assert.htmlEqual(target.innerHTML, ` diff --git a/test/runtime/samples/each-block-else-mount-or-intro/_config.js b/test/runtime/samples/each-block-else-mount-or-intro/_config.js index 8460a4b5e0..15674ea651 100644 --- a/test/runtime/samples/each-block-else-mount-or-intro/_config.js +++ b/test/runtime/samples/each-block-else-mount-or-intro/_config.js @@ -1,4 +1,4 @@ export default { props: { items: [] }, - html: `No items.`, + html: 'No items.' }; diff --git a/test/runtime/samples/each-block-empty-outro/_config.js b/test/runtime/samples/each-block-empty-outro/_config.js index 92eb7c66b1..0acf1f572f 100644 --- a/test/runtime/samples/each-block-empty-outro/_config.js +++ b/test/runtime/samples/each-block-empty-outro/_config.js @@ -13,6 +13,6 @@ export default { test({ assert, component, target }) { component.visible = false; - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/each-block-in-if-block/_config.js b/test/runtime/samples/each-block-in-if-block/_config.js index eda3ca14a9..082b9b3033 100644 --- a/test/runtime/samples/each-block-in-if-block/_config.js +++ b/test/runtime/samples/each-block-in-if-block/_config.js @@ -1,7 +1,7 @@ export default { props: { dummy: false, - fruits: ['Apple', 'Banana', 'Tomato'], + fruits: ['Apple', 'Banana', 'Tomato'] }, html: '
Apple
Banana
Tomato
', diff --git a/test/runtime/samples/each-block-indexed/_config.js b/test/runtime/samples/each-block-indexed/_config.js index f65c83ca93..bad727bbf1 100644 --- a/test/runtime/samples/each-block-indexed/_config.js +++ b/test/runtime/samples/each-block-indexed/_config.js @@ -2,5 +2,5 @@ export default { props: { animals: [ 'adder', 'blue whale', 'chameleon' ] }, - html: `

0: adder

1: blue whale

2: chameleon

` + html: '

0: adder

1: blue whale

2: chameleon

' }; diff --git a/test/runtime/samples/each-block-keyed-component-action/Component.svelte b/test/runtime/samples/each-block-keyed-component-action/Component.svelte new file mode 100644 index 0000000000..18a6c7452a --- /dev/null +++ b/test/runtime/samples/each-block-keyed-component-action/Component.svelte @@ -0,0 +1,5 @@ + + +
diff --git a/test/runtime/samples/each-block-keyed-component-action/_config.js b/test/runtime/samples/each-block-keyed-component-action/_config.js new file mode 100644 index 0000000000..a1afc44c93 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-component-action/_config.js @@ -0,0 +1,21 @@ +export default { + test({ assert, component, raf }) { + assert.equal(component.count, 0); + + component.arr = ['2']; + + assert.equal(component.count, 1); + + component.arr = ['1', '2']; + + assert.equal(component.count, 2); + + component.arr = ['2', '1']; + + assert.equal(component.count, 2); + + component.arr = []; + + assert.equal(component.count, 0); + } +}; diff --git a/test/runtime/samples/each-block-keyed-component-action/main.svelte b/test/runtime/samples/each-block-keyed-component-action/main.svelte new file mode 100644 index 0000000000..bfacdf402a --- /dev/null +++ b/test/runtime/samples/each-block-keyed-component-action/main.svelte @@ -0,0 +1,17 @@ + + +{#each arr as item (item)} + +{/each} diff --git a/test/runtime/samples/each-block-keyed-dyanmic-key/_config.js b/test/runtime/samples/each-block-keyed-dyanmic-key/_config.js new file mode 100644 index 0000000000..0aed1b0e07 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-dyanmic-key/_config.js @@ -0,0 +1,27 @@ +let count = 0; +let value = 'foo'; + +export default { + props: { + value() { + count++; + return value; + } + }, + + html: ` +
foo
+
foo
+ `, + + test({ assert, component, target }) { + value = 'bar'; + component.id = 1; + + assert.equal(count, 4); + assert.htmlEqual(target.innerHTML, ` +
bar
+
bar
+ `); + } +}; diff --git a/test/runtime/samples/each-block-keyed-dyanmic-key/main.svelte b/test/runtime/samples/each-block-keyed-dyanmic-key/main.svelte new file mode 100644 index 0000000000..9a15c7d98e --- /dev/null +++ b/test/runtime/samples/each-block-keyed-dyanmic-key/main.svelte @@ -0,0 +1,8 @@ + + +{#each ['foo', 'bar'] as key (id + key)} +
{value()}
+{/each} \ No newline at end of file diff --git a/test/runtime/samples/each-block-keyed-dynamic-2/_config.js b/test/runtime/samples/each-block-keyed-dynamic-2/_config.js index 7eba75a5ff..e25083c751 100644 --- a/test/runtime/samples/each-block-keyed-dynamic-2/_config.js +++ b/test/runtime/samples/each-block-keyed-dynamic-2/_config.js @@ -6,9 +6,9 @@ export default { `, async test({ assert, component, target, window }) { - const button = target.querySelector("button"); + const button = target.querySelector('button'); - const event = new window.MouseEvent("click"); + const event = new window.MouseEvent('click'); await button.dispatchEvent(event); assert.htmlEqual( diff --git a/test/runtime/samples/each-block-keyed-else/_config.js b/test/runtime/samples/each-block-keyed-else/_config.js new file mode 100644 index 0000000000..a5bf722a80 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-else/_config.js @@ -0,0 +1,37 @@ +export default { + props: { + animals: ['alpaca', 'baboon', 'capybara'], + foo: 'something else' + }, + + html: ` + before +

alpaca

+

baboon

+

capybara

+ after + `, + + test({ assert, component, target }) { + component.animals = []; + assert.htmlEqual(target.innerHTML, ` + before +

no animals, but rather something else

+ after + `); + + component.foo = 'something other'; + assert.htmlEqual(target.innerHTML, ` + before +

no animals, but rather something other

+ after + `); + + component.animals = ['wombat']; + assert.htmlEqual(target.innerHTML, ` + before +

wombat

+ after + `); + } +}; diff --git a/test/runtime/samples/each-block-keyed-else/main.svelte b/test/runtime/samples/each-block-keyed-else/main.svelte new file mode 100644 index 0000000000..2a82653ff1 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-else/main.svelte @@ -0,0 +1,12 @@ + + +before +{#each animals as animal (animal)} +

{animal}

+{:else} +

no animals, but rather {foo}

+{/each} +after diff --git a/test/runtime/samples/each-block-keyed-empty/_config.js b/test/runtime/samples/each-block-keyed-empty/_config.js index cf8f4d3219..dfa810b3ff 100644 --- a/test/runtime/samples/each-block-keyed-empty/_config.js +++ b/test/runtime/samples/each-block-keyed-empty/_config.js @@ -1,7 +1,7 @@ export default { props: { - x: [{ z: 1 }, { z: 2 }], + x: [{ z: 1 }, { z: 2 }] }, - html: `` + html: '' }; diff --git a/test/runtime/samples/each-block-keyed-html/_config.js b/test/runtime/samples/each-block-keyed-html/_config.js index 536e54543e..3ece052d5c 100644 --- a/test/runtime/samples/each-block-keyed-html/_config.js +++ b/test/runtime/samples/each-block-keyed-html/_config.js @@ -5,6 +5,6 @@ export default { test({ assert, component, target }) { component.names = component.names.reverse(); - assert.htmlEqual(target.innerHTML, `JillJohn`); + assert.htmlEqual(target.innerHTML, 'JillJohn'); } }; diff --git a/test/runtime/samples/each-block-keyed-non-prop/_config.js b/test/runtime/samples/each-block-keyed-non-prop/_config.js index 90e9a7f9c8..2cccbedef0 100644 --- a/test/runtime/samples/each-block-keyed-non-prop/_config.js +++ b/test/runtime/samples/each-block-keyed-non-prop/_config.js @@ -25,5 +25,5 @@ export default { assert.equal(p1, p4, 'first

element should be retained'); assert.equal(p3, p5, 'last

element should be retained'); - }, + } }; diff --git a/test/runtime/samples/each-block-keyed-random-permute/_config.js b/test/runtime/samples/each-block-keyed-random-permute/_config.js index 80bf2d9115..88330c4509 100644 --- a/test/runtime/samples/each-block-keyed-random-permute/_config.js +++ b/test/runtime/samples/each-block-keyed-random-permute/_config.js @@ -19,10 +19,10 @@ function permute() { export default { props: { - values: toObjects('abc'), + values: toObjects('abc') }, - html: `(a)(b)(c)`, + html: '(a)(b)(c)', test({ assert, component, target }) { function test(sequence) { diff --git a/test/runtime/samples/each-block-keyed-shift/_config.js b/test/runtime/samples/each-block-keyed-shift/_config.js index 44ca8447f0..4e7809445c 100644 --- a/test/runtime/samples/each-block-keyed-shift/_config.js +++ b/test/runtime/samples/each-block-keyed-shift/_config.js @@ -1,6 +1,6 @@ export default { props: { - titles: [{ name: 'a', }, { name: 'b' }, { name: 'c' }] + titles: [{ name: 'a' }, { name: 'b' }, { name: 'c' }] }, html: ` diff --git a/test/runtime/samples/each-block-keyed-siblings/_config.js b/test/runtime/samples/each-block-keyed-siblings/_config.js index d87f8943da..a52b6c404d 100644 --- a/test/runtime/samples/each-block-keyed-siblings/_config.js +++ b/test/runtime/samples/each-block-keyed-siblings/_config.js @@ -1,7 +1,7 @@ export default { props: { ones: [{ text: '1' }], - twos: [{ text: '2' }], + twos: [{ text: '2' }] }, html: ` @@ -16,5 +16,5 @@ export default {

11
2
`); - }, + } }; diff --git a/test/runtime/samples/each-block-keyed-static/_config.js b/test/runtime/samples/each-block-keyed-static/_config.js index 629ea47ebb..57800c454f 100644 --- a/test/runtime/samples/each-block-keyed-static/_config.js +++ b/test/runtime/samples/each-block-keyed-static/_config.js @@ -1,6 +1,6 @@ export default { props: { - x: [{ z: 1 }, { z: 2 }], + x: [{ z: 1 }, { z: 2 }] }, html: ` diff --git a/test/runtime/samples/each-block-scope-shadow-bind-2/_config.js b/test/runtime/samples/each-block-scope-shadow-bind-2/_config.js new file mode 100644 index 0000000000..655aac05b7 --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind-2/_config.js @@ -0,0 +1,23 @@ +export default { + html: ` + Hello + + `, + ssrHtml: ` + Hello + + `, + async test({ assert, target, window }) { + const input = target.querySelector('input'); + input.value = 'abcd'; + await input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` + abcd + + ` + ); + } +}; diff --git a/test/runtime/samples/each-block-scope-shadow-bind-2/main.svelte b/test/runtime/samples/each-block-scope-shadow-bind-2/main.svelte new file mode 100644 index 0000000000..f5bff01e6c --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind-2/main.svelte @@ -0,0 +1,10 @@ + + +{#each a as { a }} + {a} + +{/each} \ No newline at end of file diff --git a/test/runtime/samples/each-block-scope-shadow-bind-3/_config.js b/test/runtime/samples/each-block-scope-shadow-bind-3/_config.js new file mode 100644 index 0000000000..42b7a96e34 --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind-3/_config.js @@ -0,0 +1,105 @@ +export default { + html: ` +
+ Hello World + + +
+
+ Sapper App + + +
+ `, + + ssrHtml: ` +
+ Hello World + + +
+
+ Sapper App + + +
+ `, + async test({ assert, target, window }) { + const [input1, input2, input3, input4] = target.querySelectorAll('input'); + input1.value = 'Awesome'; + await input1.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ Awesome World + + +
+
+ Sapper App + + +
+ ` + ); + + input2.value = 'Svelte'; + await input2.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ Awesome Svelte + + +
+
+ Sapper App + + +
+ ` + ); + + input3.value = 'Foo'; + await input3.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ Awesome Svelte + + +
+
+ Foo App + + +
+ ` + ); + + input4.value = 'Bar'; + await input4.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ Awesome Svelte + + +
+
+ Foo Bar + + +
+ ` + ); + } +}; diff --git a/test/runtime/samples/each-block-scope-shadow-bind-3/main.svelte b/test/runtime/samples/each-block-scope-shadow-bind-3/main.svelte new file mode 100644 index 0000000000..2e8fe5e591 --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind-3/main.svelte @@ -0,0 +1,14 @@ + + +{#each a as a} +
+ {a[0]} {a[1]} + + +
+{/each} \ No newline at end of file diff --git a/test/runtime/samples/each-block-scope-shadow-bind-4/_config.js b/test/runtime/samples/each-block-scope-shadow-bind-4/_config.js new file mode 100644 index 0000000000..f0570577b2 --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind-4/_config.js @@ -0,0 +1,64 @@ +export default { + html: ` +
+ b: Hello + +
+ + `, + ssrHtml: ` +
+ b: Hello + +
+ + `, + async test({ assert, target, window }) { + const input = target.querySelector('input'); + const button = target.querySelector('button'); + + input.value = 'Awesome'; + await input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ b: Awesome + +
+ + ` + ); + + + await button.dispatchEvent(new window.MouseEvent('click')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ c: World + +
+ + ` + ); + + assert.equal(input.value, 'World'); + + input.value = 'Svelte'; + await input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` +
+ c: Svelte + +
+ + ` + ); + } +}; diff --git a/test/runtime/samples/each-block-scope-shadow-bind-4/main.svelte b/test/runtime/samples/each-block-scope-shadow-bind-4/main.svelte new file mode 100644 index 0000000000..bc4f172dd0 --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind-4/main.svelte @@ -0,0 +1,14 @@ + + +{#each a as { a, key }} +
+ {key}: {a[key]} + +
+{/each} + + \ No newline at end of file diff --git a/test/runtime/samples/each-block-scope-shadow-bind/_config.js b/test/runtime/samples/each-block-scope-shadow-bind/_config.js new file mode 100644 index 0000000000..655aac05b7 --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind/_config.js @@ -0,0 +1,23 @@ +export default { + html: ` + Hello + + `, + ssrHtml: ` + Hello + + `, + async test({ assert, target, window }) { + const input = target.querySelector('input'); + input.value = 'abcd'; + await input.dispatchEvent(new window.Event('input')); + + assert.htmlEqual( + target.innerHTML, + ` + abcd + + ` + ); + } +}; diff --git a/test/runtime/samples/each-block-scope-shadow-bind/main.svelte b/test/runtime/samples/each-block-scope-shadow-bind/main.svelte new file mode 100644 index 0000000000..f3471e179f --- /dev/null +++ b/test/runtime/samples/each-block-scope-shadow-bind/main.svelte @@ -0,0 +1,10 @@ + + +{#each a as a} + {a} + +{/each} \ No newline at end of file diff --git a/test/runtime/samples/each-block-scope-shadow-self/_config.js b/test/runtime/samples/each-block-scope-shadow-self/_config.js index 1669dc5b6e..867aadfab9 100644 --- a/test/runtime/samples/each-block-scope-shadow-self/_config.js +++ b/test/runtime/samples/each-block-scope-shadow-self/_config.js @@ -9,5 +9,5 @@ export default { assert.equal(target.querySelectorAll('input').length, 3); assert.deepEqual(component.data, { a: 'svelte', b: 'B', c: 'C' }); assert.deepEqual(component.x, ['a', 'b', 'c']); - }, + } }; diff --git a/test/runtime/samples/each-block-static/_config.js b/test/runtime/samples/each-block-static/_config.js index b62d262d9b..fc2fb28cca 100644 --- a/test/runtime/samples/each-block-static/_config.js +++ b/test/runtime/samples/each-block-static/_config.js @@ -3,10 +3,10 @@ export default { items: [] }, - html: ``, + html: '', test({ assert, component, target }) { component.items = ['x']; - assert.htmlEqual(target.innerHTML, `foo`); + assert.htmlEqual(target.innerHTML, 'foo'); } }; diff --git a/test/runtime/samples/each-block-unkeyed-else-2/_config.js b/test/runtime/samples/each-block-unkeyed-else-2/_config.js new file mode 100644 index 0000000000..a5bf722a80 --- /dev/null +++ b/test/runtime/samples/each-block-unkeyed-else-2/_config.js @@ -0,0 +1,37 @@ +export default { + props: { + animals: ['alpaca', 'baboon', 'capybara'], + foo: 'something else' + }, + + html: ` + before +

alpaca

+

baboon

+

capybara

+ after + `, + + test({ assert, component, target }) { + component.animals = []; + assert.htmlEqual(target.innerHTML, ` + before +

no animals, but rather something else

+ after + `); + + component.foo = 'something other'; + assert.htmlEqual(target.innerHTML, ` + before +

no animals, but rather something other

+ after + `); + + component.animals = ['wombat']; + assert.htmlEqual(target.innerHTML, ` + before +

wombat

+ after + `); + } +}; diff --git a/test/runtime/samples/each-block-unkeyed-else-2/main.svelte b/test/runtime/samples/each-block-unkeyed-else-2/main.svelte new file mode 100644 index 0000000000..3275cb1f83 --- /dev/null +++ b/test/runtime/samples/each-block-unkeyed-else-2/main.svelte @@ -0,0 +1,12 @@ + + +before +{#each animals as animal} +

{animal}

+{:else} +

no animals, but rather {foo}

+{/each} +after diff --git a/test/runtime/samples/each-blocks-assignment-2/_config.js b/test/runtime/samples/each-blocks-assignment-2/_config.js new file mode 100644 index 0000000000..f69b4fe9f6 --- /dev/null +++ b/test/runtime/samples/each-blocks-assignment-2/_config.js @@ -0,0 +1,20 @@ +export default { + html: ` + foo + + `, + async test({ assert, component, target, window }) { + const button = target.querySelector('button'); + + const clickEvent = new window.MouseEvent('click'); + await button.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + bar + + ` + ); + } +}; diff --git a/test/runtime/samples/each-blocks-assignment-2/main.svelte b/test/runtime/samples/each-blocks-assignment-2/main.svelte new file mode 100644 index 0000000000..5ef3ae83ac --- /dev/null +++ b/test/runtime/samples/each-blocks-assignment-2/main.svelte @@ -0,0 +1,12 @@ + + +{#each arr as o} + {o.prop} + +{/each} \ No newline at end of file diff --git a/test/runtime/samples/each-blocks-assignment/_config.js b/test/runtime/samples/each-blocks-assignment/_config.js new file mode 100644 index 0000000000..b651e3e02b --- /dev/null +++ b/test/runtime/samples/each-blocks-assignment/_config.js @@ -0,0 +1,97 @@ +export default { + html: ` + + 1 + + 2 + + 3 + + `, + async test({ assert, component, target, window }) { + let [incrementBtn, ...buttons] = target.querySelectorAll('button'); + + const clickEvent = new window.MouseEvent('click'); + await buttons[0].dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + + 2 + + 2 + + 3 + + ` + ); + + await buttons[0].dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + + 4 + + 2 + + 3 + + ` + ); + + await buttons[2].dispatchEvent(clickEvent); + await buttons[2].dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + + 4 + + 2 + + 12 + + ` + ); + + await incrementBtn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + + 4 + + 2 + + 12 + + 4 + + ` + ); + + [incrementBtn, ...buttons] = target.querySelectorAll('button'); + + await buttons[3].dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + + 4 + + 2 + + 12 + + 8 + + ` + ); + } +}; diff --git a/test/runtime/samples/each-blocks-assignment/main.svelte b/test/runtime/samples/each-blocks-assignment/main.svelte new file mode 100644 index 0000000000..f74bffbe04 --- /dev/null +++ b/test/runtime/samples/each-blocks-assignment/main.svelte @@ -0,0 +1,13 @@ + + + +{#each arr as o} + {o} + +{/each} \ No newline at end of file diff --git a/test/runtime/samples/each-blocks-expression/_config.js b/test/runtime/samples/each-blocks-expression/_config.js index 239a18b6dc..9f14bd81ec 100644 --- a/test/runtime/samples/each-blocks-expression/_config.js +++ b/test/runtime/samples/each-blocks-expression/_config.js @@ -1,3 +1,3 @@ export default { - html: `

a

b

c

` + html: '

a

b

c

' }; diff --git a/test/runtime/samples/each-blocks-nested-b/_config.js b/test/runtime/samples/each-blocks-nested-b/_config.js index c44899e6fb..7b13d988b4 100644 --- a/test/runtime/samples/each-blocks-nested-b/_config.js +++ b/test/runtime/samples/each-blocks-nested-b/_config.js @@ -28,7 +28,7 @@ export default { } ] }, - html: `

animals: aardvark

animals: buffalo

animals: chinchilla

countries: albania

countries: brazil

countries: china

people: alice

people: bob

people: carol

people: dave

`, + html: '

animals: aardvark

animals: buffalo

animals: chinchilla

countries: albania

countries: brazil

countries: china

people: alice

people: bob

people: carol

people: dave

', test({ assert, component, target }) { // TODO } diff --git a/test/runtime/samples/each-blocks-nested/_config.js b/test/runtime/samples/each-blocks-nested/_config.js index 790ec9ced7..3318bc344d 100644 --- a/test/runtime/samples/each-blocks-nested/_config.js +++ b/test/runtime/samples/each-blocks-nested/_config.js @@ -4,7 +4,7 @@ export default { rows: [ 1, 2, 3 ] }, - html: `
a, 1
a, 2
a, 3
b, 1
b, 2
b, 3
c, 1
c, 2
c, 3
`, + html: '
a, 1
a, 2
a, 3
b, 1
b, 2
b, 3
c, 1
c, 2
c, 3
', test({ assert, component, target }) { // TODO diff --git a/test/runtime/samples/element-source-location/_config.js b/test/runtime/samples/element-source-location/_config.js index 61ae36d107..101cc2cad1 100644 --- a/test/runtime/samples/element-source-location/_config.js +++ b/test/runtime/samples/element-source-location/_config.js @@ -23,4 +23,4 @@ export default { char: 7 }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/empty-dom/_config.js b/test/runtime/samples/empty-dom/_config.js index e3e3d0ecd5..22dc25b41e 100644 --- a/test/runtime/samples/empty-dom/_config.js +++ b/test/runtime/samples/empty-dom/_config.js @@ -1,3 +1,3 @@ export default { - html: '', -}; \ No newline at end of file + html: '' +}; diff --git a/test/runtime/samples/empty-style-block/_config.js b/test/runtime/samples/empty-style-block/_config.js index 0375bad029..22dc25b41e 100644 --- a/test/runtime/samples/empty-style-block/_config.js +++ b/test/runtime/samples/empty-style-block/_config.js @@ -1,3 +1,3 @@ export default { - html: '', + html: '' }; diff --git a/test/runtime/samples/escape-template-literals/_config.js b/test/runtime/samples/escape-template-literals/_config.js index 1419d65679..9e50f94764 100644 --- a/test/runtime/samples/escape-template-literals/_config.js +++ b/test/runtime/samples/escape-template-literals/_config.js @@ -1,3 +1,3 @@ export default { - html: '`${foo}\\n`\n
foo
\n
`${foo}\\n`
', + html: '`${foo}\\n`\n
foo
\n
`${foo}\\n`
' }; diff --git a/test/runtime/samples/event-handler-async/_config.js b/test/runtime/samples/event-handler-async/_config.js index fab4d998b6..b483d039ed 100644 --- a/test/runtime/samples/event-handler-async/_config.js +++ b/test/runtime/samples/event-handler-async/_config.js @@ -1,5 +1,5 @@ export default { html: ` - `, + ` }; diff --git a/test/runtime/samples/event-handler-dynamic-2/_config.js b/test/runtime/samples/event-handler-dynamic-2/_config.js index c996d8f2aa..5fded47855 100644 --- a/test/runtime/samples/event-handler-dynamic-2/_config.js +++ b/test/runtime/samples/event-handler-dynamic-2/_config.js @@ -29,5 +29,5 @@ export default { await handler_b.dispatchEvent(event); assert.equal(p.innerHTML, '2'); - }, + } }; diff --git a/test/runtime/samples/event-handler-dynamic-bound-var/_config.js b/test/runtime/samples/event-handler-dynamic-bound-var/_config.js index c832127c09..c490db000a 100644 --- a/test/runtime/samples/event-handler-dynamic-bound-var/_config.js +++ b/test/runtime/samples/event-handler-dynamic-bound-var/_config.js @@ -16,5 +16,5 @@ export default { Bye World ` ); - }, + } }; diff --git a/test/runtime/samples/event-handler-dynamic-expression/_config.js b/test/runtime/samples/event-handler-dynamic-expression/_config.js index c4d259a542..f479c9cef2 100644 --- a/test/runtime/samples/event-handler-dynamic-expression/_config.js +++ b/test/runtime/samples/event-handler-dynamic-expression/_config.js @@ -1,5 +1,5 @@ export default { - html: ``, + html: '', async test({ assert, component, target, window }) { const [button] = target.querySelectorAll( @@ -9,12 +9,12 @@ export default { const event = new window.MouseEvent('click'); await button.dispatchEvent(event); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); await button.dispatchEvent(event); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); await button.dispatchEvent(event); - assert.htmlEqual(target.innerHTML, ``); - }, + assert.htmlEqual(target.innerHTML, ''); + } }; diff --git a/test/runtime/samples/event-handler-dynamic-hash/_config.js b/test/runtime/samples/event-handler-dynamic-hash/_config.js index e60e561524..35f5fa103d 100644 --- a/test/runtime/samples/event-handler-dynamic-hash/_config.js +++ b/test/runtime/samples/event-handler-dynamic-hash/_config.js @@ -14,14 +14,14 @@ export default { ); const event = new window.MouseEvent('click'); - let err = ""; + let err = ''; window.addEventListener('error', (e) => { e.preventDefault(); err = e.message; }); await button.dispatchEvent(event); - assert.equal(err, "", err); + assert.equal(err, '', err); assert.htmlEqual(target.innerHTML, `

@@ -52,5 +52,5 @@ export default {

2

`); - }, + } }; diff --git a/test/runtime/samples/event-handler-dynamic-invalid/_config.js b/test/runtime/samples/event-handler-dynamic-invalid/_config.js index ba1777f945..0ed298c95a 100644 --- a/test/runtime/samples/event-handler-dynamic-invalid/_config.js +++ b/test/runtime/samples/event-handler-dynamic-invalid/_config.js @@ -9,7 +9,7 @@ export default { ); const event = new window.MouseEvent('click'); - let err = ""; + let err = ''; window.addEventListener('error', (e) => { e.preventDefault(); err = e.message; @@ -17,12 +17,12 @@ export default { // All three should not throw if proper checking is done in runtime code await buttonUndef.dispatchEvent(event); - assert.equal(err, "", err); + assert.equal(err, '', err); await buttonNull.dispatchEvent(event); - assert.equal(err, "", err); + assert.equal(err, '', err); await buttonInvalid.dispatchEvent(event); - assert.equal(err, "", err); - }, + assert.equal(err, '', err); + } }; diff --git a/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js b/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js index 6d7d29e482..6bd96ba8aa 100644 --- a/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js +++ b/test/runtime/samples/event-handler-dynamic-modifier-self/_config.js @@ -12,5 +12,5 @@ export default { await button.dispatchEvent(event); assert.ok(!component.inner_clicked); - }, + } }; diff --git a/test/runtime/samples/event-handler-dynamic/_config.js b/test/runtime/samples/event-handler-dynamic/_config.js index e60e561524..35f5fa103d 100644 --- a/test/runtime/samples/event-handler-dynamic/_config.js +++ b/test/runtime/samples/event-handler-dynamic/_config.js @@ -14,14 +14,14 @@ export default { ); const event = new window.MouseEvent('click'); - let err = ""; + let err = ''; window.addEventListener('error', (e) => { e.preventDefault(); err = e.message; }); await button.dispatchEvent(event); - assert.equal(err, "", err); + assert.equal(err, '', err); assert.htmlEqual(target.innerHTML, `

@@ -52,5 +52,5 @@ export default {

2

`); - }, + } }; diff --git a/test/runtime/samples/event-handler-each-modifier/_config.js b/test/runtime/samples/event-handler-each-modifier/_config.js new file mode 100644 index 0000000000..8274e22eec --- /dev/null +++ b/test/runtime/samples/event-handler-each-modifier/_config.js @@ -0,0 +1,42 @@ +export default { + async test({ assert, component, target, window }) { + // set first + await component.lists.update(() => [ + { text: 'item1' }, + { text: 'item2' }, + { text: 'item3' } + ]); + + await component.lists.update(() => [ + { text: 'item3' }, + { text: 'item2' }, + { text: 'item1' } + ]); + + await component.lists.update(() => [ + { text: 'item1' }, + { text: 'item2' }, + { text: 'item3' } + ]); + + assert.equal(component.updated, 4); + + const [item1, item2] = target.childNodes; + const [item1Btn1, item1Btn2] = item1.querySelectorAll('button'); + const [item2Btn1, item2Btn2] = item2.querySelectorAll('button'); + + const clickEvent = new window.MouseEvent('click'); + + await item1Btn1.dispatchEvent(clickEvent); + assert.equal(component.getNormalCount(), 1); + + await item1Btn2.dispatchEvent(clickEvent); + assert.equal(component.getModifierCount(), 1); + + await item2Btn1.dispatchEvent(clickEvent); + assert.equal(component.getNormalCount(), 2); + + await item2Btn2.dispatchEvent(clickEvent); + assert.equal(component.getModifierCount(), 2); + } +}; diff --git a/test/runtime/samples/event-handler-each-modifier/main.svelte b/test/runtime/samples/event-handler-each-modifier/main.svelte new file mode 100644 index 0000000000..ca7447f728 --- /dev/null +++ b/test/runtime/samples/event-handler-each-modifier/main.svelte @@ -0,0 +1,37 @@ + + +{#each $lists as item (item.text)} +
+ {item.text} + + +
+{/each} diff --git a/test/runtime/samples/event-handler-each-this/_config.js b/test/runtime/samples/event-handler-each-this/_config.js index 3ab2d5acdc..7f6528977c 100644 --- a/test/runtime/samples/event-handler-each-this/_config.js +++ b/test/runtime/samples/event-handler-each-this/_config.js @@ -1,6 +1,6 @@ export default { props: { - items: ['foo', 'bar', 'baz'], + items: ['foo', 'bar', 'baz'] }, html: ` diff --git a/test/runtime/samples/event-handler-modifier-self/_config.js b/test/runtime/samples/event-handler-modifier-self/_config.js index 6d7d29e482..6bd96ba8aa 100644 --- a/test/runtime/samples/event-handler-modifier-self/_config.js +++ b/test/runtime/samples/event-handler-modifier-self/_config.js @@ -12,5 +12,5 @@ export default { await button.dispatchEvent(event); assert.ok(!component.inner_clicked); - }, + } }; diff --git a/test/runtime/samples/flush-before-bindings/_config.js b/test/runtime/samples/flush-before-bindings/_config.js index 7bb6ebfc15..4f20299771 100644 --- a/test/runtime/samples/flush-before-bindings/_config.js +++ b/test/runtime/samples/flush-before-bindings/_config.js @@ -20,4 +20,4 @@ export default { // TODO minimise the number of recomputations during oncreate // assert.equal(counter.count, 1); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/flush-before-bindings/counter.js b/test/runtime/samples/flush-before-bindings/counter.js index 63872cd6a2..f0fc271f84 100644 --- a/test/runtime/samples/flush-before-bindings/counter.js +++ b/test/runtime/samples/flush-before-bindings/counter.js @@ -1,3 +1,3 @@ export default { count: 0 -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/fragment-trailing-whitespace/_config.js b/test/runtime/samples/fragment-trailing-whitespace/_config.js index 2251d6dae8..549cb1be68 100644 --- a/test/runtime/samples/fragment-trailing-whitespace/_config.js +++ b/test/runtime/samples/fragment-trailing-whitespace/_config.js @@ -1,5 +1,5 @@ -const message = "the quick brown fox jumps over the lazy dog"; -const expected = [...message].map(c => `${c + " "}`).join(""); +const message = 'the quick brown fox jumps over the lazy dog'; +const expected = [...message].map(c => `${c + ' '}`).join(''); export default { props: { diff --git a/test/runtime/samples/function-expression-inline/_config.js b/test/runtime/samples/function-expression-inline/_config.js index 6916be45b1..a5dc3f7080 100644 --- a/test/runtime/samples/function-expression-inline/_config.js +++ b/test/runtime/samples/function-expression-inline/_config.js @@ -19,4 +19,4 @@ export default {

6

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/function-in-expression/_config.js b/test/runtime/samples/function-in-expression/_config.js index f8ddbe26a5..d3086863d3 100644 --- a/test/runtime/samples/function-in-expression/_config.js +++ b/test/runtime/samples/function-in-expression/_config.js @@ -8,6 +8,6 @@ export default { test({ assert, component, target }) { component.numbers = [10, 11, 12, 13, 14, 15, 16]; - assert.htmlEqual(target.innerHTML, `11, 13, 15`); + assert.htmlEqual(target.innerHTML, '11, 13, 15'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/get-after-destroy/_config.js b/test/runtime/samples/get-after-destroy/_config.js index 5d10bbe72a..5e3171d39a 100644 --- a/test/runtime/samples/get-after-destroy/_config.js +++ b/test/runtime/samples/get-after-destroy/_config.js @@ -3,7 +3,7 @@ export default { foo: 1 }, - html: `
1
`, + html: '
1
', test({ assert, component }) { component.$destroy(); diff --git a/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js b/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js index d5f3def7f1..34cee8157c 100644 --- a/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js +++ b/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js @@ -37,17 +37,17 @@ export default { todos: { first: { description: 'Buy some milk', - done: true, + done: true }, second: { description: 'Do the laundry', - done: true, + done: true }, third: { description: "Find life's true purpose", - done: false, - }, - }, + done: false + } + } }, async test({ assert, component, target, window }) { @@ -74,5 +74,5 @@ export default {
`); - }, + } }; diff --git a/test/runtime/samples/globals-shadowed-by-each-binding/_config.js b/test/runtime/samples/globals-shadowed-by-each-binding/_config.js index f69e5e8b0e..50feb09bb6 100644 --- a/test/runtime/samples/globals-shadowed-by-each-binding/_config.js +++ b/test/runtime/samples/globals-shadowed-by-each-binding/_config.js @@ -1,3 +1,3 @@ export default { - html: '

Alert1

Alert2

', + html: '

Alert1

Alert2

' }; diff --git a/test/runtime/samples/hash-in-attribute/_config.js b/test/runtime/samples/hash-in-attribute/_config.js index 5e5726c48f..a6fe8eb909 100644 --- a/test/runtime/samples/hash-in-attribute/_config.js +++ b/test/runtime/samples/hash-in-attribute/_config.js @@ -23,4 +23,4 @@ export default { x#f `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/head-title-dynamic-simple/_config.js b/test/runtime/samples/head-title-dynamic-simple/_config.js index 682a841fcd..cc2301a2f9 100644 --- a/test/runtime/samples/head-title-dynamic-simple/_config.js +++ b/test/runtime/samples/head-title-dynamic-simple/_config.js @@ -9,4 +9,4 @@ export default { component.foo = 'Also A Title'; assert.equal(window.document.title, 'Also A Title'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/head-title-dynamic/_config.js b/test/runtime/samples/head-title-dynamic/_config.js index ddb04bf0a3..95d5f8debf 100644 --- a/test/runtime/samples/head-title-dynamic/_config.js +++ b/test/runtime/samples/head-title-dynamic/_config.js @@ -9,4 +9,4 @@ export default { component.adjective = 'different'; assert.equal(window.document.title, 'a different title'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/head-title-empty/_config.js b/test/runtime/samples/head-title-empty/_config.js index 497855156c..5b0785c797 100644 --- a/test/runtime/samples/head-title-empty/_config.js +++ b/test/runtime/samples/head-title-empty/_config.js @@ -2,4 +2,4 @@ export default { test({ assert, window }) { assert.equal(window.document.title, ''); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/head-title-static/_config.js b/test/runtime/samples/head-title-static/_config.js index e6d5d9aaff..ee9a0316b5 100644 --- a/test/runtime/samples/head-title-static/_config.js +++ b/test/runtime/samples/head-title-static/_config.js @@ -2,4 +2,4 @@ export default { test({ assert, component, target, window }) { assert.equal(window.document.title, 'changed'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/html-entities-inside-elements/_config.js b/test/runtime/samples/html-entities-inside-elements/_config.js index a53af0a297..2537da2654 100644 --- a/test/runtime/samples/html-entities-inside-elements/_config.js +++ b/test/runtime/samples/html-entities-inside-elements/_config.js @@ -2,4 +2,4 @@ export default { html: `

this <em>should</em> not be <strong>bold</strong>

` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/html-entities/_config.js b/test/runtime/samples/html-entities/_config.js index c8c2de8403..ddcc318e28 100644 --- a/test/runtime/samples/html-entities/_config.js +++ b/test/runtime/samples/html-entities/_config.js @@ -11,4 +11,4 @@ export default { &notanentity; ` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/html-non-entities-inside-elements/_config.js b/test/runtime/samples/html-non-entities-inside-elements/_config.js index bc217d6d02..d8e128a117 100644 --- a/test/runtime/samples/html-non-entities-inside-elements/_config.js +++ b/test/runtime/samples/html-non-entities-inside-elements/_config.js @@ -2,4 +2,4 @@ export default { html: `
'foo'
` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/if-block-component-store-function-conditionals/_config.js b/test/runtime/samples/if-block-component-store-function-conditionals/_config.js index db171f2fd1..609765d225 100644 --- a/test/runtime/samples/if-block-component-store-function-conditionals/_config.js +++ b/test/runtime/samples/if-block-component-store-function-conditionals/_config.js @@ -1,3 +1,3 @@ export default { - html: '

OK

', + html: '

OK

' }; diff --git a/test/runtime/samples/if-block-component-without-outro/_config.js b/test/runtime/samples/if-block-component-without-outro/_config.js index 8106081c7c..fbcc328fa3 100644 --- a/test/runtime/samples/if-block-component-without-outro/_config.js +++ b/test/runtime/samples/if-block-component-without-outro/_config.js @@ -1,6 +1,6 @@ export default { props: { - foo: true, + foo: true }, html: '
A wild component appears
', @@ -8,5 +8,5 @@ export default { test({ assert, component, target }) { component.foo = false; assert.htmlEqual(target.innerHTML, ''); - }, + } }; diff --git a/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js b/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js index 58b0521022..bcc4e256a4 100644 --- a/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js +++ b/test/runtime/samples/if-block-compound-outro-no-dependencies/_config.js @@ -1,3 +1,3 @@ export default { - html: `blah blah blah blah` + html: 'blah blah blah blah' }; diff --git a/test/runtime/samples/if-block-conservative-update/_config.js b/test/runtime/samples/if-block-conservative-update/_config.js index a71166ef81..f84ccb6b43 100644 --- a/test/runtime/samples/if-block-conservative-update/_config.js +++ b/test/runtime/samples/if-block-conservative-update/_config.js @@ -9,7 +9,7 @@ export default { } }, - html: `

potato

`, + html: '

potato

', test({ assert, component, target }) { assert.equal(count, 1); @@ -17,6 +17,6 @@ export default { component.foo = 'soup'; assert.equal(count, 1); - assert.htmlEqual(target.innerHTML, `

soup

`); + assert.htmlEqual(target.innerHTML, '

soup

'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/if-block-else-conservative-update/_config.js b/test/runtime/samples/if-block-else-conservative-update/_config.js index 5c90d2ad3a..da83385dd5 100644 --- a/test/runtime/samples/if-block-else-conservative-update/_config.js +++ b/test/runtime/samples/if-block-else-conservative-update/_config.js @@ -15,7 +15,7 @@ export default { } }, - html: `

potato

`, + html: '

potato

', test({ assert, component, target }) { assert.equal(count_a, 1); @@ -26,12 +26,12 @@ export default { assert.equal(count_a, 2); assert.equal(count_b, 1); - assert.htmlEqual(target.innerHTML, `

SOUP

`); + assert.htmlEqual(target.innerHTML, '

SOUP

'); component.foo = 'salad'; assert.equal(count_a, 3); assert.equal(count_b, 1); - assert.htmlEqual(target.innerHTML, `

SALAD

`); + assert.htmlEqual(target.innerHTML, '

SALAD

'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/if-block-else-in-each/_config.js b/test/runtime/samples/if-block-else-in-each/_config.js index 44268f32b9..e75dcb15ee 100644 --- a/test/runtime/samples/if-block-else-in-each/_config.js +++ b/test/runtime/samples/if-block-else-in-each/_config.js @@ -1,9 +1,9 @@ export default { props: { - array: [true, false], + array: [true, false] }, html: `
foo
bar
- `, + ` }; diff --git a/test/runtime/samples/if-block-else-partial-outro/_config.js b/test/runtime/samples/if-block-else-partial-outro/_config.js index a358680edf..ae58d25c23 100644 --- a/test/runtime/samples/if-block-else-partial-outro/_config.js +++ b/test/runtime/samples/if-block-else-partial-outro/_config.js @@ -1,7 +1,7 @@ export default { props: { x: 1, - y: false, + y: false }, html: ` @@ -13,5 +13,5 @@ export default { assert.htmlEqual(target.innerHTML, ` 2 `); - }, + } }; diff --git a/test/runtime/samples/if-block-elseif-no-else/_config.js b/test/runtime/samples/if-block-elseif-no-else/_config.js index ec3379737a..e9696e513c 100644 --- a/test/runtime/samples/if-block-elseif-no-else/_config.js +++ b/test/runtime/samples/if-block-elseif-no-else/_config.js @@ -14,6 +14,6 @@ export default { `); component.x = 6; - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); } }; diff --git a/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js b/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js index b2e71ea01f..da80f5be12 100644 --- a/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js +++ b/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js @@ -18,5 +18,5 @@ export default {

y

`); - }, + } }; diff --git a/test/runtime/samples/if-block-outro-unique-select-block-type/_config.js b/test/runtime/samples/if-block-outro-unique-select-block-type/_config.js index b94da1a576..15213e19b3 100644 --- a/test/runtime/samples/if-block-outro-unique-select-block-type/_config.js +++ b/test/runtime/samples/if-block-outro-unique-select-block-type/_config.js @@ -2,5 +2,5 @@ export default { html: `
- `, + ` }; diff --git a/test/runtime/samples/if-block-static-with-elseif-else-and-outros/RRR.svelte b/test/runtime/samples/if-block-static-with-elseif-else-and-outros/RRR.svelte new file mode 100644 index 0000000000..7242373249 --- /dev/null +++ b/test/runtime/samples/if-block-static-with-elseif-else-and-outros/RRR.svelte @@ -0,0 +1 @@ +rrr \ No newline at end of file diff --git a/test/runtime/samples/if-block-static-with-elseif-else-and-outros/_config.js b/test/runtime/samples/if-block-static-with-elseif-else-and-outros/_config.js new file mode 100644 index 0000000000..8b2c6d2d66 --- /dev/null +++ b/test/runtime/samples/if-block-static-with-elseif-else-and-outros/_config.js @@ -0,0 +1,3 @@ +export default { + html: 'eee' +}; diff --git a/test/runtime/samples/if-block-static-with-elseif-else-and-outros/main.svelte b/test/runtime/samples/if-block-static-with-elseif-else-and-outros/main.svelte new file mode 100644 index 0000000000..b60885722e --- /dev/null +++ b/test/runtime/samples/if-block-static-with-elseif-else-and-outros/main.svelte @@ -0,0 +1,13 @@ + + +{#if "Eva".startsWith('E')} + eee +{:else if x} + def +{:else} + +{/if} diff --git a/test/runtime/samples/ignore-unchanged-attribute-compound/counter.js b/test/runtime/samples/ignore-unchanged-attribute-compound/counter.js index 63872cd6a2..f0fc271f84 100644 --- a/test/runtime/samples/ignore-unchanged-attribute-compound/counter.js +++ b/test/runtime/samples/ignore-unchanged-attribute-compound/counter.js @@ -1,3 +1,3 @@ export default { count: 0 -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/ignore-unchanged-attribute/counter.js b/test/runtime/samples/ignore-unchanged-attribute/counter.js index 63872cd6a2..f0fc271f84 100644 --- a/test/runtime/samples/ignore-unchanged-attribute/counter.js +++ b/test/runtime/samples/ignore-unchanged-attribute/counter.js @@ -1,3 +1,3 @@ export default { count: 0 -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/ignore-unchanged-raw/counter.js b/test/runtime/samples/ignore-unchanged-raw/counter.js index 63872cd6a2..f0fc271f84 100644 --- a/test/runtime/samples/ignore-unchanged-raw/counter.js +++ b/test/runtime/samples/ignore-unchanged-raw/counter.js @@ -1,3 +1,3 @@ export default { count: 0 -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/ignore-unchanged-tag/counter.js b/test/runtime/samples/ignore-unchanged-tag/counter.js index 63872cd6a2..f0fc271f84 100644 --- a/test/runtime/samples/ignore-unchanged-tag/counter.js +++ b/test/runtime/samples/ignore-unchanged-tag/counter.js @@ -1,3 +1,3 @@ export default { count: 0 -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/immutable-option/_config.js b/test/runtime/samples/immutable-option/_config.js index 1224d0213a..4962d2d3b7 100644 --- a/test/runtime/samples/immutable-option/_config.js +++ b/test/runtime/samples/immutable-option/_config.js @@ -1,11 +1,11 @@ export default { immutable: true, - html: `

Called 1 times.

`, + html: '

Called 1 times.

', test({ assert, component, target }) { // eslint-disable-next-line no-self-assign component.foo = component.foo; - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + assert.htmlEqual(target.innerHTML, '

Called 1 times.

'); } }; diff --git a/test/runtime/samples/immutable-svelte-meta-false/_config.js b/test/runtime/samples/immutable-svelte-meta-false/_config.js index 664f99f087..1506e79227 100644 --- a/test/runtime/samples/immutable-svelte-meta-false/_config.js +++ b/test/runtime/samples/immutable-svelte-meta-false/_config.js @@ -1,11 +1,11 @@ export default { immutable: true, - html: `

Called 1 times.

`, + html: '

Called 1 times.

', test({ assert, component, target }) { // eslint-disable-next-line no-self-assign component.foo = component.foo; - assert.htmlEqual(target.innerHTML, `

Called 2 times.

`); + assert.htmlEqual(target.innerHTML, '

Called 2 times.

'); } }; diff --git a/test/runtime/samples/immutable-svelte-meta/_config.js b/test/runtime/samples/immutable-svelte-meta/_config.js index 4e39f36224..2dfb6cd3db 100644 --- a/test/runtime/samples/immutable-svelte-meta/_config.js +++ b/test/runtime/samples/immutable-svelte-meta/_config.js @@ -1,9 +1,9 @@ export default { - html: `

Called 1 times.

`, + html: '

Called 1 times.

', test({ assert, component, target }) { // eslint-disable-next-line no-self-assign component.foo = component.foo; - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + assert.htmlEqual(target.innerHTML, '

Called 1 times.

'); } }; diff --git a/test/runtime/samples/imported-renamed-components/_config.js b/test/runtime/samples/imported-renamed-components/_config.js index 9a9e325b84..07683b05be 100644 --- a/test/runtime/samples/imported-renamed-components/_config.js +++ b/test/runtime/samples/imported-renamed-components/_config.js @@ -1,3 +1,3 @@ export default { - html: `OneTwo` + html: 'OneTwo' }; diff --git a/test/runtime/samples/initial-state-assign/_config.js b/test/runtime/samples/initial-state-assign/_config.js index b4067fef80..95a1a5e068 100644 --- a/test/runtime/samples/initial-state-assign/_config.js +++ b/test/runtime/samples/initial-state-assign/_config.js @@ -3,5 +3,5 @@ export default { html: ` "foo" "bar" - `, + ` }; diff --git a/test/runtime/samples/inline-style-important/_config.js b/test/runtime/samples/inline-style-important/_config.js index b7c8d2c352..53f4e98db3 100644 --- a/test/runtime/samples/inline-style-important/_config.js +++ b/test/runtime/samples/inline-style-important/_config.js @@ -15,4 +15,4 @@ export default { styles = window.getComputedStyle(p); assert.equal(styles.color, 'green'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/inline-style-optimisation-bailout/_config.js b/test/runtime/samples/inline-style-optimisation-bailout/_config.js index 836a3e2e6e..acc41e3160 100644 --- a/test/runtime/samples/inline-style-optimisation-bailout/_config.js +++ b/test/runtime/samples/inline-style-optimisation-bailout/_config.js @@ -17,4 +17,4 @@ export default { assert.equal(styles.color, ''); assert.equal(styles.fontSize, '20px'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/innerhtml-interpolated-literal/_config.js b/test/runtime/samples/innerhtml-interpolated-literal/_config.js index 022c70f717..d2f4d94a31 100644 --- a/test/runtime/samples/innerhtml-interpolated-literal/_config.js +++ b/test/runtime/samples/innerhtml-interpolated-literal/_config.js @@ -4,4 +4,4 @@ export default {
` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/innerhtml-with-comments/_config.js b/test/runtime/samples/innerhtml-with-comments/_config.js new file mode 100644 index 0000000000..897d54c573 --- /dev/null +++ b/test/runtime/samples/innerhtml-with-comments/_config.js @@ -0,0 +1,8 @@ +export default { + html: ` + + Style: + Bootstrap. + + ` +}; diff --git a/test/runtime/samples/innerhtml-with-comments/main.svelte b/test/runtime/samples/innerhtml-with-comments/main.svelte new file mode 100644 index 0000000000..e00f755072 --- /dev/null +++ b/test/runtime/samples/innerhtml-with-comments/main.svelte @@ -0,0 +1,5 @@ + + Style: + + Bootstrap. + \ No newline at end of file diff --git a/test/runtime/samples/instrumentation-auto-subscription-self-assignment/_config.js b/test/runtime/samples/instrumentation-auto-subscription-self-assignment/_config.js index f70a80fe44..32cd6fc22d 100644 --- a/test/runtime/samples/instrumentation-auto-subscription-self-assignment/_config.js +++ b/test/runtime/samples/instrumentation-auto-subscription-self-assignment/_config.js @@ -1,8 +1,8 @@ export default { - html: `[]`, + html: '[]', async test({ assert, component, target }) { await component.go(); - assert.htmlEqual(target.innerHTML, `[42]`); + assert.htmlEqual(target.innerHTML, '[42]'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-script-destructuring/_config.js b/test/runtime/samples/instrumentation-script-destructuring/_config.js index a0b2de9e77..2b677a8b3a 100644 --- a/test/runtime/samples/instrumentation-script-destructuring/_config.js +++ b/test/runtime/samples/instrumentation-script-destructuring/_config.js @@ -26,4 +26,4 @@ export default {

x: 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-script-loop-scope/_config.js b/test/runtime/samples/instrumentation-script-loop-scope/_config.js index 1195055c45..069114c523 100644 --- a/test/runtime/samples/instrumentation-script-loop-scope/_config.js +++ b/test/runtime/samples/instrumentation-script-loop-scope/_config.js @@ -14,4 +14,4 @@ export default {

x: 42

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-script-multiple-assignments/_config.js b/test/runtime/samples/instrumentation-script-multiple-assignments/_config.js index c5107e4964..1c4663938f 100644 --- a/test/runtime/samples/instrumentation-script-multiple-assignments/_config.js +++ b/test/runtime/samples/instrumentation-script-multiple-assignments/_config.js @@ -25,4 +25,4 @@ export default {

bar: 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-script-update/_config.js b/test/runtime/samples/instrumentation-script-update/_config.js index 4e97140faf..223904ad63 100644 --- a/test/runtime/samples/instrumentation-script-update/_config.js +++ b/test/runtime/samples/instrumentation-script-update/_config.js @@ -14,4 +14,4 @@ export default {

x: 1

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-template-destructuring/_config.js b/test/runtime/samples/instrumentation-template-destructuring/_config.js index a0b2de9e77..2b677a8b3a 100644 --- a/test/runtime/samples/instrumentation-template-destructuring/_config.js +++ b/test/runtime/samples/instrumentation-template-destructuring/_config.js @@ -26,4 +26,4 @@ export default {

x: 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-template-loop-scope/_config.js b/test/runtime/samples/instrumentation-template-loop-scope/_config.js index 1195055c45..069114c523 100644 --- a/test/runtime/samples/instrumentation-template-loop-scope/_config.js +++ b/test/runtime/samples/instrumentation-template-loop-scope/_config.js @@ -14,4 +14,4 @@ export default {

x: 42

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-template-multiple-assignments/_config.js b/test/runtime/samples/instrumentation-template-multiple-assignments/_config.js index c5107e4964..1c4663938f 100644 --- a/test/runtime/samples/instrumentation-template-multiple-assignments/_config.js +++ b/test/runtime/samples/instrumentation-template-multiple-assignments/_config.js @@ -25,4 +25,4 @@ export default {

bar: 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/instrumentation-template-update/_config.js b/test/runtime/samples/instrumentation-template-update/_config.js index 4e97140faf..223904ad63 100644 --- a/test/runtime/samples/instrumentation-template-update/_config.js +++ b/test/runtime/samples/instrumentation-template-update/_config.js @@ -14,4 +14,4 @@ export default {

x: 1

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/invalidation-in-if-condition/_config.js b/test/runtime/samples/invalidation-in-if-condition/_config.js index 27209c75c9..25e7811889 100644 --- a/test/runtime/samples/invalidation-in-if-condition/_config.js +++ b/test/runtime/samples/invalidation-in-if-condition/_config.js @@ -1,17 +1,17 @@ export default { - html: ``, + html: '', async test({ assert, target, window }) { const button = target.querySelector('button'); const click = new window.MouseEvent('click'); await button.dispatchEvent(click); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); await button.dispatchEvent(click); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); await button.dispatchEvent(click); - assert.htmlEqual(target.innerHTML, ``); + assert.htmlEqual(target.innerHTML, ''); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/isolated-text/_config.js b/test/runtime/samples/isolated-text/_config.js index ec4332be5c..4dc29eb838 100644 --- a/test/runtime/samples/isolated-text/_config.js +++ b/test/runtime/samples/isolated-text/_config.js @@ -3,4 +3,4 @@ export default { before

after

` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/key-block-2/_config.js b/test/runtime/samples/key-block-2/_config.js new file mode 100644 index 0000000000..9bbf1f199f --- /dev/null +++ b/test/runtime/samples/key-block-2/_config.js @@ -0,0 +1,14 @@ +// with reactive content beside `key` +export default { + html: '
00
', + async test({ assert, component, target, window }) { + const div = target.querySelector('div'); + component.reactive = 2; + assert.htmlEqual(target.innerHTML, '
02
'); + assert.strictEqual(div, target.querySelector('div')); + + component.value = 5; + assert.htmlEqual(target.innerHTML, '
52
'); + assert.notStrictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-2/main.svelte b/test/runtime/samples/key-block-2/main.svelte new file mode 100644 index 0000000000..466d20b10a --- /dev/null +++ b/test/runtime/samples/key-block-2/main.svelte @@ -0,0 +1,8 @@ + + +{#key value} +
{value}{reactive}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-3/_config.js b/test/runtime/samples/key-block-3/_config.js new file mode 100644 index 0000000000..17b6146827 --- /dev/null +++ b/test/runtime/samples/key-block-3/_config.js @@ -0,0 +1,11 @@ +// key is not used in the template +export default { + html: '
', + async test({ assert, component, target, window }) { + const div = target.querySelector('div'); + + component.value = 5; + assert.htmlEqual(target.innerHTML, '
'); + assert.notStrictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-3/main.svelte b/test/runtime/samples/key-block-3/main.svelte new file mode 100644 index 0000000000..1ed185c732 --- /dev/null +++ b/test/runtime/samples/key-block-3/main.svelte @@ -0,0 +1,7 @@ + + +{#key value} +
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-array-immutable/_config.js b/test/runtime/samples/key-block-array-immutable/_config.js new file mode 100644 index 0000000000..b1ffd6cd15 --- /dev/null +++ b/test/runtime/samples/key-block-array-immutable/_config.js @@ -0,0 +1,15 @@ +export default { + html: '
1
', + async test({ assert, component, target, window }) { + let div = target.querySelector('div'); + await component.append(2); + assert.htmlEqual(target.innerHTML, '
1
'); + assert.strictEqual(div, target.querySelector('div')); + + div = target.querySelector('div'); + + component.array = [3, 4]; + assert.htmlEqual(target.innerHTML, '
3,4
'); + assert.notStrictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-array-immutable/main.svelte b/test/runtime/samples/key-block-array-immutable/main.svelte new file mode 100644 index 0000000000..e666275af4 --- /dev/null +++ b/test/runtime/samples/key-block-array-immutable/main.svelte @@ -0,0 +1,14 @@ + + + + +{#key array} +
{array.join(',')}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-array/_config.js b/test/runtime/samples/key-block-array/_config.js new file mode 100644 index 0000000000..374175177d --- /dev/null +++ b/test/runtime/samples/key-block-array/_config.js @@ -0,0 +1,15 @@ +export default { + html: '
1
', + async test({ assert, component, target, window }) { + let div = target.querySelector('div'); + await component.append(2); + assert.htmlEqual(target.innerHTML, '
1,2
'); + assert.notStrictEqual(div, target.querySelector('div')); + + div = target.querySelector('div'); + + component.array = [3, 4]; + assert.htmlEqual(target.innerHTML, '
3,4
'); + assert.notStrictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-array/main.svelte b/test/runtime/samples/key-block-array/main.svelte new file mode 100644 index 0000000000..5a4054b043 --- /dev/null +++ b/test/runtime/samples/key-block-array/main.svelte @@ -0,0 +1,12 @@ + + +{#key array} +
{array.join(',')}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-expression-2/_config.js b/test/runtime/samples/key-block-expression-2/_config.js new file mode 100644 index 0000000000..bab23d2a84 --- /dev/null +++ b/test/runtime/samples/key-block-expression-2/_config.js @@ -0,0 +1,18 @@ +export default { + html: '
3
', + async test({ assert, component, target, window }) { + const div = target.querySelector('div'); + + await component.mutate(); + assert.htmlEqual(target.innerHTML, '
5
'); + assert.strictEqual(div, target.querySelector('div')); + + await component.reassign(); + assert.htmlEqual(target.innerHTML, '
7
'); + assert.strictEqual(div, target.querySelector('div')); + + await component.changeKey(); + assert.htmlEqual(target.innerHTML, '
7
'); + assert.notStrictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-expression-2/main.svelte b/test/runtime/samples/key-block-expression-2/main.svelte new file mode 100644 index 0000000000..5525f63761 --- /dev/null +++ b/test/runtime/samples/key-block-expression-2/main.svelte @@ -0,0 +1,17 @@ + + +{#key obj.key} +
{obj.value}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-expression/_config.js b/test/runtime/samples/key-block-expression/_config.js new file mode 100644 index 0000000000..c04d55bd29 --- /dev/null +++ b/test/runtime/samples/key-block-expression/_config.js @@ -0,0 +1,28 @@ +export default { + html: '
000
', + async test({ assert, component, target, window }) { + let div = target.querySelector('div'); + component.value = 2; + assert.htmlEqual(target.innerHTML, '
200
'); + assert.notStrictEqual(div, target.querySelector('div')); + + div = target.querySelector('div'); + + component.anotherValue = 5; + assert.htmlEqual(target.innerHTML, '
250
'); + assert.notStrictEqual(div, target.querySelector('div')); + + div = target.querySelector('div'); + + component.thirdValue = 9; + assert.htmlEqual(target.innerHTML, '
259
'); + assert.strictEqual(div, target.querySelector('div')); + + // make dirty while maintain the value of `value + anotherValue` + // should update the content, but not recreate the elements + await component.$set({ value: 4, anotherValue: 3 }); + + assert.htmlEqual(target.innerHTML, '
439
'); + assert.strictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-expression/main.svelte b/test/runtime/samples/key-block-expression/main.svelte new file mode 100644 index 0000000000..dd752e8b8f --- /dev/null +++ b/test/runtime/samples/key-block-expression/main.svelte @@ -0,0 +1,9 @@ + + +{#key value + anotherValue} +
{value}{anotherValue}{thirdValue}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-static/_config.js b/test/runtime/samples/key-block-static/_config.js new file mode 100644 index 0000000000..8323336615 --- /dev/null +++ b/test/runtime/samples/key-block-static/_config.js @@ -0,0 +1,9 @@ +export default { + html: '
00
', + async test({ assert, component, target, window }) { + const div = target.querySelector('div'); + component.anotherValue = 2; + assert.htmlEqual(target.innerHTML, '
02
'); + assert.strictEqual(div, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-static/main.svelte b/test/runtime/samples/key-block-static/main.svelte new file mode 100644 index 0000000000..e4ee6b5d71 --- /dev/null +++ b/test/runtime/samples/key-block-static/main.svelte @@ -0,0 +1,8 @@ + + +{#key value} +
{value}{anotherValue}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block-transition/_config.js b/test/runtime/samples/key-block-transition/_config.js new file mode 100644 index 0000000000..53de6b333c --- /dev/null +++ b/test/runtime/samples/key-block-transition/_config.js @@ -0,0 +1,24 @@ +export default { + html: '
0
', + async test({ assert, component, target, window, raf }) { + component.value = 2; + + const [div1, div2] = target.querySelectorAll('div'); + + assert.htmlEqual(div1.outerHTML, '
0
'); + assert.htmlEqual(div2.outerHTML, '
2
'); + + raf.tick(0); + + assert.equal(div1.foo, 1); + assert.equal(div1.oof, 0); + + assert.equal(div2.foo, 0); + assert.equal(div2.oof, 1); + + raf.tick(200); + + assert.htmlEqual(target.innerHTML, '
2
'); + assert.equal(div2, target.querySelector('div')); + } +}; diff --git a/test/runtime/samples/key-block-transition/main.svelte b/test/runtime/samples/key-block-transition/main.svelte new file mode 100644 index 0000000000..d7fb6ec024 --- /dev/null +++ b/test/runtime/samples/key-block-transition/main.svelte @@ -0,0 +1,17 @@ + + +{#key value} +
{value}
+{/key} \ No newline at end of file diff --git a/test/runtime/samples/key-block/_config.js b/test/runtime/samples/key-block/_config.js new file mode 100644 index 0000000000..b25ca901f8 --- /dev/null +++ b/test/runtime/samples/key-block/_config.js @@ -0,0 +1,17 @@ +export default { + html: '
0
0
', + async test({ assert, component, target, window }) { + let [div1, div2] = target.querySelectorAll('div'); + + component.value = 5; + assert.htmlEqual(target.innerHTML, '
5
0
'); + assert.notStrictEqual(div1, target.querySelectorAll('div')[0]); + assert.strictEqual(div2, target.querySelectorAll('div')[1]); + [div1, div2] = target.querySelectorAll('div'); + + component.reactive = 10; + assert.htmlEqual(target.innerHTML, '
5
10
'); + assert.strictEqual(div1, target.querySelectorAll('div')[0]); + assert.strictEqual(div2, target.querySelectorAll('div')[1]); + } +}; diff --git a/test/runtime/samples/key-block/main.svelte b/test/runtime/samples/key-block/main.svelte new file mode 100644 index 0000000000..ac3c340770 --- /dev/null +++ b/test/runtime/samples/key-block/main.svelte @@ -0,0 +1,10 @@ + + +{#key value} +
{value}
+{/key} + +
{reactive}
\ No newline at end of file diff --git a/test/runtime/samples/keyed-each-dev-unique/_config.js b/test/runtime/samples/keyed-each-dev-unique/_config.js index 8f46af9d52..81728d9c15 100644 --- a/test/runtime/samples/keyed-each-dev-unique/_config.js +++ b/test/runtime/samples/keyed-each-dev-unique/_config.js @@ -3,5 +3,5 @@ export default { dev: true }, - error: `Cannot have duplicate keys in a keyed each` + error: 'Cannot have duplicate keys in a keyed each' }; diff --git a/test/runtime/samples/lifecycle-render-order-for-children/_config.js b/test/runtime/samples/lifecycle-render-order-for-children/_config.js index 033b593aea..d182d5a97e 100644 --- a/test/runtime/samples/lifecycle-render-order-for-children/_config.js +++ b/test/runtime/samples/lifecycle-render-order-for-children/_config.js @@ -21,7 +21,7 @@ export default { '3: onMount', '3: afterUpdate', '0: onMount', - '0: afterUpdate', + '0: afterUpdate' ]); } else { assert.deepEqual(order, [ @@ -40,10 +40,10 @@ export default { '3: onMount', '3: afterUpdate', '0: onMount', - '0: afterUpdate', + '0: afterUpdate' ]); } order.length = 0; - }, + } }; diff --git a/test/runtime/samples/lifecycle-render-order-for-children/order.js b/test/runtime/samples/lifecycle-render-order-for-children/order.js index 109fa8b38c..d6d1738de6 100644 --- a/test/runtime/samples/lifecycle-render-order-for-children/order.js +++ b/test/runtime/samples/lifecycle-render-order-for-children/order.js @@ -1 +1 @@ -export default []; \ No newline at end of file +export default []; diff --git a/test/runtime/samples/lifecycle-render-order/order.js b/test/runtime/samples/lifecycle-render-order/order.js index 109fa8b38c..d6d1738de6 100644 --- a/test/runtime/samples/lifecycle-render-order/order.js +++ b/test/runtime/samples/lifecycle-render-order/order.js @@ -1 +1 @@ -export default []; \ No newline at end of file +export default []; diff --git a/test/runtime/samples/loop-protect-generator-opt-out/_config.js b/test/runtime/samples/loop-protect-generator-opt-out/_config.js new file mode 100644 index 0000000000..0fe83a36db --- /dev/null +++ b/test/runtime/samples/loop-protect-generator-opt-out/_config.js @@ -0,0 +1,6 @@ +export default { + compileOptions: { + dev: true, + loopGuardTimeout: 1 + } +}; diff --git a/test/runtime/samples/loop-protect-generator-opt-out/main.svelte b/test/runtime/samples/loop-protect-generator-opt-out/main.svelte new file mode 100644 index 0000000000..a7aa790681 --- /dev/null +++ b/test/runtime/samples/loop-protect-generator-opt-out/main.svelte @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/test/runtime/samples/loop-protect-inner-function/_config.js b/test/runtime/samples/loop-protect-inner-function/_config.js index 862d4f4c0f..1b553e2475 100644 --- a/test/runtime/samples/loop-protect-inner-function/_config.js +++ b/test/runtime/samples/loop-protect-inner-function/_config.js @@ -2,6 +2,6 @@ export default { html: '
', compileOptions: { dev: true, - loopGuardTimeout: 100, + loopGuardTimeout: 100 } }; diff --git a/test/runtime/samples/loop-protect/_config.js b/test/runtime/samples/loop-protect/_config.js index 75f75c003d..230bbeb53d 100644 --- a/test/runtime/samples/loop-protect/_config.js +++ b/test/runtime/samples/loop-protect/_config.js @@ -2,6 +2,6 @@ export default { error: 'Infinite loop detected', compileOptions: { dev: true, - loopGuardTimeout: 100, + loopGuardTimeout: 100 } }; diff --git a/test/runtime/samples/module-context-export/_config.js b/test/runtime/samples/module-context-export/_config.js index 902501fdd4..4c4595483a 100644 --- a/test/runtime/samples/module-context-export/_config.js +++ b/test/runtime/samples/module-context-export/_config.js @@ -1,3 +1,3 @@ export default { - html: `

(42)(99)

` -}; \ No newline at end of file + html: '

(42)(99)

' +}; diff --git a/test/runtime/samples/module-context-with-instance-script/_config.js b/test/runtime/samples/module-context-with-instance-script/_config.js index 902501fdd4..4c4595483a 100644 --- a/test/runtime/samples/module-context-with-instance-script/_config.js +++ b/test/runtime/samples/module-context-with-instance-script/_config.js @@ -1,3 +1,3 @@ export default { - html: `

(42)(99)

` -}; \ No newline at end of file + html: '

(42)(99)

' +}; diff --git a/test/runtime/samples/module-context/_config.js b/test/runtime/samples/module-context/_config.js index 0ea26ee446..83138d08f9 100644 --- a/test/runtime/samples/module-context/_config.js +++ b/test/runtime/samples/module-context/_config.js @@ -1,3 +1,3 @@ export default { - html: `

42

` -}; \ No newline at end of file + html: '

42

' +}; diff --git a/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js b/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js index 038db6dbbb..8d51c61394 100644 --- a/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js +++ b/test/runtime/samples/mutation-tracking-across-sibling-scopes/_config.js @@ -9,4 +9,4 @@ export default { assert.htmlEqual(component.div.innerHTML, '
-
-
'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/names-deconflicted/_config.js b/test/runtime/samples/names-deconflicted/_config.js index 07b337a1e8..9ce1010690 100644 --- a/test/runtime/samples/names-deconflicted/_config.js +++ b/test/runtime/samples/names-deconflicted/_config.js @@ -1,5 +1,5 @@ export default { - html: `

1: foo

2: bar

3: baz

`, + html: '

1: foo

2: bar

3: baz

', test({ assert, component, target }) { component.widgets = [ @@ -7,6 +7,6 @@ export default { { name: 'bosh' } ]; - assert.htmlEqual( target.innerHTML, `

1: bish

2: bosh

` ); + assert.htmlEqual( target.innerHTML, '

1: bish

2: bosh

' ); } }; diff --git a/test/runtime/samples/nbsp/_config.js b/test/runtime/samples/nbsp/_config.js index 6322725f98..5cfbc4ca35 100644 --- a/test/runtime/samples/nbsp/_config.js +++ b/test/runtime/samples/nbsp/_config.js @@ -1,8 +1,8 @@ export default { - html: ` `, + html: ' ', test({ assert, component, target }) { const text = target.querySelector( 'span' ).textContent; assert.equal( text.charCodeAt( 0 ), 160 ); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/nested-transition-detach-each/_config.js b/test/runtime/samples/nested-transition-detach-each/_config.js index e17fe1bc4d..41d32e597c 100644 --- a/test/runtime/samples/nested-transition-detach-each/_config.js +++ b/test/runtime/samples/nested-transition-detach-each/_config.js @@ -5,7 +5,7 @@ export default { cols: ['a', 'b', 'c'] }, - html: ``, + html: '', compileOptions: { dev: true @@ -34,6 +34,6 @@ export default { component.visible = false; raf.tick(0); raf.tick(100); - assert.htmlEqual(target.innerHTML, ``); - }, + assert.htmlEqual(target.innerHTML, ''); + } }; diff --git a/test/runtime/samples/nested-transition-detach-if-false/_config.js b/test/runtime/samples/nested-transition-detach-if-false/_config.js index d2ae78ffe3..1d42094192 100644 --- a/test/runtime/samples/nested-transition-detach-if-false/_config.js +++ b/test/runtime/samples/nested-transition-detach-if-false/_config.js @@ -20,5 +20,5 @@ export default { a `); - }, + } }; diff --git a/test/runtime/samples/nested-transition-if-block-not-remounted/_config.js b/test/runtime/samples/nested-transition-if-block-not-remounted/_config.js index 6696389e6e..1f2d5561fe 100644 --- a/test/runtime/samples/nested-transition-if-block-not-remounted/_config.js +++ b/test/runtime/samples/nested-transition-if-block-not-remounted/_config.js @@ -11,14 +11,13 @@ export default {
`, - test({ assert, component, target, window, raf }) { + test({ component, target }) { const div = target.querySelector('div'); - const { appendChild, insertBefore } = div; div.appendChild = div.insertBefore = () => { throw new Error('DOM was mutated'); }; component.value = 'two'; - }, + } }; diff --git a/test/runtime/samples/noscript-removal/_config.js b/test/runtime/samples/noscript-removal/_config.js index 35bdcefd96..709792c14a 100644 --- a/test/runtime/samples/noscript-removal/_config.js +++ b/test/runtime/samples/noscript-removal/_config.js @@ -5,5 +5,5 @@ export default {
foo
foo
foo
-`, +` }; diff --git a/test/runtime/samples/numeric-seperator/_config.js b/test/runtime/samples/numeric-seperator/_config.js new file mode 100644 index 0000000000..2b1b5168ee --- /dev/null +++ b/test/runtime/samples/numeric-seperator/_config.js @@ -0,0 +1,3 @@ +export default { + html: '2048 2048' +}; diff --git a/test/runtime/samples/numeric-seperator/main.svelte b/test/runtime/samples/numeric-seperator/main.svelte new file mode 100644 index 0000000000..e491b8a107 --- /dev/null +++ b/test/runtime/samples/numeric-seperator/main.svelte @@ -0,0 +1,5 @@ + + +{num} {2_048} \ No newline at end of file diff --git a/test/runtime/samples/observable-auto-subscribe/_config.js b/test/runtime/samples/observable-auto-subscribe/_config.js index 289a3b51c6..5570413395 100644 --- a/test/runtime/samples/observable-auto-subscribe/_config.js +++ b/test/runtime/samples/observable-auto-subscribe/_config.js @@ -23,7 +23,7 @@ export default { visible: false }, - html: ``, + html: '', async test({ assert, component, target }) { assert.equal(subscribers.length, 0); @@ -46,4 +46,4 @@ export default { assert.equal(subscribers.length, 0); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/ondestroy-before-cleanup/_config.js b/test/runtime/samples/ondestroy-before-cleanup/_config.js index e9721f24b0..e33b154b64 100644 --- a/test/runtime/samples/ondestroy-before-cleanup/_config.js +++ b/test/runtime/samples/ondestroy-before-cleanup/_config.js @@ -4,10 +4,9 @@ export default { test({ assert, component, target }) { container.div = null; - const top = component.top; const div = target.querySelector('div'); component.visible = false; assert.equal(container.div, div); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/ondestroy-before-cleanup/container.js b/test/runtime/samples/ondestroy-before-cleanup/container.js index 7c645e42fb..ff8b4c5632 100644 --- a/test/runtime/samples/ondestroy-before-cleanup/container.js +++ b/test/runtime/samples/ondestroy-before-cleanup/container.js @@ -1 +1 @@ -export default {}; \ No newline at end of file +export default {}; diff --git a/test/runtime/samples/ondestroy-deep/_config.js b/test/runtime/samples/ondestroy-deep/_config.js index 4431a2e163..3f82e8b601 100644 --- a/test/runtime/samples/ondestroy-deep/_config.js +++ b/test/runtime/samples/ondestroy-deep/_config.js @@ -7,4 +7,4 @@ export default { reset(); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/ondestroy-deep/destroyed.js b/test/runtime/samples/ondestroy-deep/destroyed.js index fe05c1d241..45845cbd83 100644 --- a/test/runtime/samples/ondestroy-deep/destroyed.js +++ b/test/runtime/samples/ondestroy-deep/destroyed.js @@ -1,3 +1,3 @@ export const destroyed = []; -export const reset = () => destroyed.length = 0; \ No newline at end of file +export const reset = () => destroyed.length = 0; diff --git a/test/runtime/samples/onmount-fires-when-ready-nested/_config.js b/test/runtime/samples/onmount-fires-when-ready-nested/_config.js index b7446c1d72..4f7ec9b051 100644 --- a/test/runtime/samples/onmount-fires-when-ready-nested/_config.js +++ b/test/runtime/samples/onmount-fires-when-ready-nested/_config.js @@ -1,5 +1,5 @@ export default { skip_if_ssr: true, // uses oncreate - html: `

true

\n

true

` + html: '

true

\n

true

' }; diff --git a/test/runtime/samples/onmount-fires-when-ready/_config.js b/test/runtime/samples/onmount-fires-when-ready/_config.js index de095cbdb7..ca9f535c19 100644 --- a/test/runtime/samples/onmount-fires-when-ready/_config.js +++ b/test/runtime/samples/onmount-fires-when-ready/_config.js @@ -1,10 +1,10 @@ export default { skip_if_ssr: true, // uses oncreate - html: `

true

`, + html: '

true

', test({ assert, component, target }) { component.foo = true; - assert.htmlEqual(target.innerHTML, `

true

\n

true

`); + assert.htmlEqual(target.innerHTML, '

true

\n

true

'); } }; diff --git a/test/runtime/samples/onmount-get-current-component/_config.js b/test/runtime/samples/onmount-get-current-component/_config.js new file mode 100644 index 0000000000..6c5c666cf0 --- /dev/null +++ b/test/runtime/samples/onmount-get-current-component/_config.js @@ -0,0 +1,4 @@ +export default { + skip_if_ssr: true, + html: '1' +}; diff --git a/test/runtime/samples/onmount-get-current-component/main.svelte b/test/runtime/samples/onmount-get-current-component/main.svelte new file mode 100644 index 0000000000..de64bc65fa --- /dev/null +++ b/test/runtime/samples/onmount-get-current-component/main.svelte @@ -0,0 +1,16 @@ + + +{gotException} diff --git a/test/runtime/samples/onmount-sibling-order/result.js b/test/runtime/samples/onmount-sibling-order/result.js index 109fa8b38c..d6d1738de6 100644 --- a/test/runtime/samples/onmount-sibling-order/result.js +++ b/test/runtime/samples/onmount-sibling-order/result.js @@ -1 +1 @@ -export default []; \ No newline at end of file +export default []; diff --git a/test/runtime/samples/option-without-select/_config.js b/test/runtime/samples/option-without-select/_config.js index 48303961ad..9925069bb1 100644 --- a/test/runtime/samples/option-without-select/_config.js +++ b/test/runtime/samples/option-without-select/_config.js @@ -3,7 +3,7 @@ export default { foo: 'hello' }, - html: ``, + html: "", test({ assert, component, target }) { component.foo = 'goodbye'; @@ -11,4 +11,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/paren-wrapped-expressions/_config.js b/test/runtime/samples/paren-wrapped-expressions/_config.js index 0c757dc854..972dc51cb0 100644 --- a/test/runtime/samples/paren-wrapped-expressions/_config.js +++ b/test/runtime/samples/paren-wrapped-expressions/_config.js @@ -2,7 +2,7 @@ export default { props: { a: 'foo', b: true, - c: [ 1, 2, 3 ], + c: [ 1, 2, 3 ] }, html: ` diff --git a/test/runtime/samples/preload/_config.js b/test/runtime/samples/preload/_config.js index 1b35ebbe74..d7d5fd0851 100644 --- a/test/runtime/samples/preload/_config.js +++ b/test/runtime/samples/preload/_config.js @@ -2,4 +2,4 @@ export default { test({ assert, mod }) { assert.deepEqual(mod.preload({ foo: 1 }), { bar: 2 }); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/prop-const/_config.js b/test/runtime/samples/prop-const/_config.js index 489a48476f..991063a754 100644 --- a/test/runtime/samples/prop-const/_config.js +++ b/test/runtime/samples/prop-const/_config.js @@ -20,4 +20,4 @@ export default {

b: 2

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/prop-exports/_config.js b/test/runtime/samples/prop-exports/_config.js index e1620c015f..69a40c4fab 100644 --- a/test/runtime/samples/prop-exports/_config.js +++ b/test/runtime/samples/prop-exports/_config.js @@ -10,7 +10,7 @@ export default { a2: 4, a6: writable(29), for: 'loop', - continue: '...', + continue: '...' }, html: ` diff --git a/test/runtime/samples/prop-not-action/_config.js b/test/runtime/samples/prop-not-action/_config.js index 17ab47b584..1f4ffa4749 100644 --- a/test/runtime/samples/prop-not-action/_config.js +++ b/test/runtime/samples/prop-not-action/_config.js @@ -6,4 +6,4 @@ export default { html: `

Hello world!

` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/prop-quoted/_config.js b/test/runtime/samples/prop-quoted/_config.js index d982bc87cc..aa2f2ec329 100644 --- a/test/runtime/samples/prop-quoted/_config.js +++ b/test/runtime/samples/prop-quoted/_config.js @@ -3,10 +3,10 @@ export default { foo: 1 }, - html: `1`, + html: '1', async test({ assert, component, target }) { component.foo = 2; - assert.htmlEqual(target.innerHTML, `2`); + assert.htmlEqual(target.innerHTML, '2'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/prop-subscribable/_config.js b/test/runtime/samples/prop-subscribable/_config.js index 84cde8c9af..fcd8fb8b07 100644 --- a/test/runtime/samples/prop-subscribable/_config.js +++ b/test/runtime/samples/prop-subscribable/_config.js @@ -8,4 +8,4 @@ export default { html: ` 42 ` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/prop-without-semicolon-b/_config.js b/test/runtime/samples/prop-without-semicolon-b/_config.js index 7104dc2b2d..6cdc86c521 100644 --- a/test/runtime/samples/prop-without-semicolon-b/_config.js +++ b/test/runtime/samples/prop-without-semicolon-b/_config.js @@ -3,5 +3,5 @@ export default { name: 'world' }, - html: `

Hello world!

` -}; \ No newline at end of file + html: '

Hello world!

' +}; diff --git a/test/runtime/samples/prop-without-semicolon/_config.js b/test/runtime/samples/prop-without-semicolon/_config.js index 328d6cc2eb..26b3554f9f 100644 --- a/test/runtime/samples/prop-without-semicolon/_config.js +++ b/test/runtime/samples/prop-without-semicolon/_config.js @@ -1,3 +1,3 @@ export default { - html: `

Hello world!

` -}; \ No newline at end of file + html: '

Hello world!

' +}; diff --git a/test/runtime/samples/props-reactive-b/_config.js b/test/runtime/samples/props-reactive-b/_config.js index 43eaee23aa..541fd26e02 100644 --- a/test/runtime/samples/props-reactive-b/_config.js +++ b/test/runtime/samples/props-reactive-b/_config.js @@ -27,4 +27,4 @@ export default {

c: 9

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/props-reactive-only-with-change/Comp.svelte b/test/runtime/samples/props-reactive-only-with-change/Comp.svelte new file mode 100644 index 0000000000..0eaf8a40d4 --- /dev/null +++ b/test/runtime/samples/props-reactive-only-with-change/Comp.svelte @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/test/runtime/samples/props-reactive-only-with-change/_config.js b/test/runtime/samples/props-reactive-only-with-change/_config.js new file mode 100644 index 0000000000..dcf12868f9 --- /dev/null +++ b/test/runtime/samples/props-reactive-only-with-change/_config.js @@ -0,0 +1,30 @@ +let callbacks = []; + +export default { + props: { + callback: (value) => callbacks.push(value), + val1: '1', + val2: '2' + }, + + before_test() { + callbacks = []; + }, + + async test({ assert, component, target }) { + assert.equal(callbacks.length, 2); + assert.equal(JSON.stringify(callbacks), '["1","2"]'); + + component.val1 = '3'; + assert.equal(callbacks.length, 3); + assert.equal(JSON.stringify(callbacks), '["1","2","1"]'); + + component.val1 = '4'; + assert.equal(callbacks.length, 4); + assert.equal(JSON.stringify(callbacks), '["1","2","1","1"]'); + + component.val2 = '5'; + assert.equal(callbacks.length, 5); + assert.equal(JSON.stringify(callbacks), '["1","2","1","1","2"]'); + } +}; diff --git a/test/runtime/samples/props-reactive-only-with-change/main.svelte b/test/runtime/samples/props-reactive-only-with-change/main.svelte new file mode 100644 index 0000000000..73ddd137f5 --- /dev/null +++ b/test/runtime/samples/props-reactive-only-with-change/main.svelte @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/test/runtime/samples/props-reactive-slot/Comp.svelte b/test/runtime/samples/props-reactive-slot/Comp.svelte new file mode 100644 index 0000000000..bf9e12a58a --- /dev/null +++ b/test/runtime/samples/props-reactive-slot/Comp.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/props-reactive-slot/_config.js b/test/runtime/samples/props-reactive-slot/_config.js new file mode 100644 index 0000000000..266f0fc8a8 --- /dev/null +++ b/test/runtime/samples/props-reactive-slot/_config.js @@ -0,0 +1,21 @@ +export default { + html: ` +

hi

+ + `, + + async test({ assert, component, target, window }) { + const btn = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` +

changed

+ + ` + ); + } +}; diff --git a/test/runtime/samples/props-reactive-slot/main.svelte b/test/runtime/samples/props-reactive-slot/main.svelte new file mode 100644 index 0000000000..84777bf8ab --- /dev/null +++ b/test/runtime/samples/props-reactive-slot/main.svelte @@ -0,0 +1,13 @@ + + + +

+ {props.someprop} +

+
+ + \ No newline at end of file diff --git a/test/runtime/samples/props-reactive/_config.js b/test/runtime/samples/props-reactive/_config.js index a44687069e..4c27ac0618 100644 --- a/test/runtime/samples/props-reactive/_config.js +++ b/test/runtime/samples/props-reactive/_config.js @@ -17,4 +17,4 @@ export default {

5

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/props/_config.js b/test/runtime/samples/props/_config.js index fc3c71d6f0..64015cdc6b 100644 --- a/test/runtime/samples/props/_config.js +++ b/test/runtime/samples/props/_config.js @@ -14,4 +14,4 @@ export default {

{"x":2}

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/raw-anchor-first-child/_config.js b/test/runtime/samples/raw-anchor-first-child/_config.js index 32f948bcbb..02297675c5 100644 --- a/test/runtime/samples/raw-anchor-first-child/_config.js +++ b/test/runtime/samples/raw-anchor-first-child/_config.js @@ -1,12 +1,12 @@ export default { props: { - raw: `foo` + raw: 'foo' }, test({ assert, component, target }) { const span = target.querySelector('span'); assert.ok(!span.previousSibling); - component.raw = `bar`; + component.raw = 'bar'; } }; diff --git a/test/runtime/samples/raw-anchor-first-last-child/_config.js b/test/runtime/samples/raw-anchor-first-last-child/_config.js index 31f8c343ed..30acfe4d0f 100644 --- a/test/runtime/samples/raw-anchor-first-last-child/_config.js +++ b/test/runtime/samples/raw-anchor-first-last-child/_config.js @@ -1,6 +1,6 @@ export default { props: { - raw: `foo` + raw: 'foo' }, test({ assert, component, target }) { @@ -8,6 +8,6 @@ export default { assert.ok(!span.previousSibling); assert.ok(!span.nextSibling); - component.raw = `bar`; + component.raw = 'bar'; } }; diff --git a/test/runtime/samples/raw-anchor-last-child/_config.js b/test/runtime/samples/raw-anchor-last-child/_config.js index ea2217b4c1..dcc8ac6db6 100644 --- a/test/runtime/samples/raw-anchor-last-child/_config.js +++ b/test/runtime/samples/raw-anchor-last-child/_config.js @@ -1,12 +1,12 @@ export default { props: { - raw: `foo` + raw: 'foo' }, test({ assert, component, target }) { const span = target.querySelector('span'); assert.ok(!span.nextSibling); - component.raw = `bar`; + component.raw = 'bar'; } }; diff --git a/test/runtime/samples/raw-anchor-next-previous-sibling/_config.js b/test/runtime/samples/raw-anchor-next-previous-sibling/_config.js index d28e84fc3b..c6d2b561c0 100644 --- a/test/runtime/samples/raw-anchor-next-previous-sibling/_config.js +++ b/test/runtime/samples/raw-anchor-next-previous-sibling/_config.js @@ -1,6 +1,6 @@ export default { props: { - raw: `foo` + raw: 'foo' }, test({ assert, component, target }) { @@ -8,6 +8,6 @@ export default { assert.equal(span.previousSibling.nodeName, 'BR'); assert.equal(span.nextSibling.nodeName, 'BR'); - component.raw = `bar`; + component.raw = 'bar'; } }; diff --git a/test/runtime/samples/raw-anchor-next-sibling/_config.js b/test/runtime/samples/raw-anchor-next-sibling/_config.js index dc6ad98e2e..1982f28da5 100644 --- a/test/runtime/samples/raw-anchor-next-sibling/_config.js +++ b/test/runtime/samples/raw-anchor-next-sibling/_config.js @@ -1,12 +1,12 @@ export default { props: { - raw: `foo` + raw: 'foo' }, test({ assert, component, target }) { const span = target.querySelector('span'); assert.equal(span.previousSibling.nodeName, 'BR'); - component.raw = `bar`; + component.raw = 'bar'; } }; diff --git a/test/runtime/samples/raw-anchor-previous-sibling/_config.js b/test/runtime/samples/raw-anchor-previous-sibling/_config.js index dc6ad98e2e..1982f28da5 100644 --- a/test/runtime/samples/raw-anchor-previous-sibling/_config.js +++ b/test/runtime/samples/raw-anchor-previous-sibling/_config.js @@ -1,12 +1,12 @@ export default { props: { - raw: `foo` + raw: 'foo' }, test({ assert, component, target }) { const span = target.querySelector('span'); assert.equal(span.previousSibling.nodeName, 'BR'); - component.raw = `bar`; + component.raw = 'bar'; } }; diff --git a/test/runtime/samples/raw-mustache-as-root/RawMustache.svelte b/test/runtime/samples/raw-mustache-as-root/RawMustache.svelte new file mode 100644 index 0000000000..d94954f49b --- /dev/null +++ b/test/runtime/samples/raw-mustache-as-root/RawMustache.svelte @@ -0,0 +1,5 @@ + + +{@html content} \ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-as-root/_config.js b/test/runtime/samples/raw-mustache-as-root/_config.js new file mode 100644 index 0000000000..a38c0b1c81 --- /dev/null +++ b/test/runtime/samples/raw-mustache-as-root/_config.js @@ -0,0 +1,33 @@ +export default { + html: ` + +

Another first line

+

This line should be last.

+ `, + async test({ assert, target, window }) { + const btn = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

First line

+

This line should be last.

+ ` + ); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

Another first line

+

This line should be last.

+ ` + ); + } +}; diff --git a/test/runtime/samples/raw-mustache-as-root/main.svelte b/test/runtime/samples/raw-mustache-as-root/main.svelte new file mode 100644 index 0000000000..7ccce0cd9b --- /dev/null +++ b/test/runtime/samples/raw-mustache-as-root/main.svelte @@ -0,0 +1,17 @@ + + + + + + +

This line should be last.

\ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-before-element/_config.js b/test/runtime/samples/raw-mustache-before-element/_config.js index 61288cbb52..e00ca11a20 100644 --- a/test/runtime/samples/raw-mustache-before-element/_config.js +++ b/test/runtime/samples/raw-mustache-before-element/_config.js @@ -1,3 +1,3 @@ export default { - html: `

xbaz

` + html: '

xbaz

' }; diff --git a/test/runtime/samples/raw-mustache-inside-head/_config.js b/test/runtime/samples/raw-mustache-inside-head/_config.js new file mode 100644 index 0000000000..6d28a6e8c4 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-head/_config.js @@ -0,0 +1,16 @@ +export default { + async test({ assert, target, window }) { + const btn = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + assert.equal(window.document.head.innerHTML.includes(''), true); + + await btn.dispatchEvent(clickEvent); + + assert.equal(window.document.head.innerHTML.includes(''), true); + + await btn.dispatchEvent(clickEvent); + + assert.equal(window.document.head.innerHTML.includes(''), true); + } +}; diff --git a/test/runtime/samples/raw-mustache-inside-head/main.svelte b/test/runtime/samples/raw-mustache-inside-head/main.svelte new file mode 100644 index 0000000000..25b9fdeee9 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-head/main.svelte @@ -0,0 +1,16 @@ + + + + + + {@html content} + + diff --git a/test/runtime/samples/raw-mustache-inside-slot/Component.svelte b/test/runtime/samples/raw-mustache-inside-slot/Component.svelte new file mode 100644 index 0000000000..fcabccae48 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-slot/Component.svelte @@ -0,0 +1,2 @@ + +

This line should be last.

\ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-inside-slot/_config.js b/test/runtime/samples/raw-mustache-inside-slot/_config.js new file mode 100644 index 0000000000..a38c0b1c81 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-slot/_config.js @@ -0,0 +1,33 @@ +export default { + html: ` + +

Another first line

+

This line should be last.

+ `, + async test({ assert, target, window }) { + const btn = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

First line

+

This line should be last.

+ ` + ); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +

Another first line

+

This line should be last.

+ ` + ); + } +}; diff --git a/test/runtime/samples/raw-mustache-inside-slot/main.svelte b/test/runtime/samples/raw-mustache-inside-slot/main.svelte new file mode 100644 index 0000000000..a022a68e95 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-slot/main.svelte @@ -0,0 +1,17 @@ + + + + + + {@html content} + \ No newline at end of file diff --git a/test/runtime/samples/raw-mustaches-preserved/_config.js b/test/runtime/samples/raw-mustaches-preserved/_config.js index 66b829f7cb..d4d57025d2 100644 --- a/test/runtime/samples/raw-mustaches-preserved/_config.js +++ b/test/runtime/samples/raw-mustaches-preserved/_config.js @@ -5,13 +5,13 @@ export default { raw: '

does not change

' }, - html: `

does not change

`, + html: '

does not change

', test({ assert, component, target }) { const p = target.querySelector('p'); component.raw = '

does not change

'; - assert.equal(target.innerHTML, `

does not change

`); + assert.equal(target.innerHTML, '

does not change

'); assert.strictEqual(target.querySelector('p'), p); } }; diff --git a/test/runtime/samples/raw-mustaches-td-tr/_config.js b/test/runtime/samples/raw-mustaches-td-tr/_config.js new file mode 100644 index 0000000000..3b165bb65e --- /dev/null +++ b/test/runtime/samples/raw-mustaches-td-tr/_config.js @@ -0,0 +1,18 @@ +export default { + props: { + raw: '12' + }, + + html: ` + + + + + + + + + +
57
12
+ ` +}; diff --git a/test/runtime/samples/raw-mustaches-td-tr/main.svelte b/test/runtime/samples/raw-mustaches-td-tr/main.svelte new file mode 100644 index 0000000000..07d7299e43 --- /dev/null +++ b/test/runtime/samples/raw-mustaches-td-tr/main.svelte @@ -0,0 +1,12 @@ + + + + + + + + {@html raw} + +
57
\ No newline at end of file diff --git a/test/runtime/samples/raw-mustaches/_config.js b/test/runtime/samples/raw-mustaches/_config.js index cc9999aa34..9eda8289ce 100644 --- a/test/runtime/samples/raw-mustaches/_config.js +++ b/test/runtime/samples/raw-mustaches/_config.js @@ -5,13 +5,13 @@ export default { raw: 'raw html!!!\\o/' }, - html: `beforeraw html!!!\\o/after`, + html: 'beforeraw html!!!\\o/after', test({ assert, component, target }) { component.raw = ''; - assert.equal(target.innerHTML, `beforeafter`); + assert.equal(target.innerHTML, 'beforeafter'); component.raw = 'how about unclosed elements?'; - assert.equal(target.innerHTML, `beforehow about unclosed elements?after`); + assert.equal(target.innerHTML, 'beforehow about unclosed elements?after'); component.$destroy(); assert.equal(target.innerHTML, ''); } diff --git a/test/runtime/samples/reactive-assignment-in-assignment-rhs/_config.js b/test/runtime/samples/reactive-assignment-in-assignment-rhs/_config.js index f0bf2cdc70..0402f34a2f 100644 --- a/test/runtime/samples/reactive-assignment-in-assignment-rhs/_config.js +++ b/test/runtime/samples/reactive-assignment-in-assignment-rhs/_config.js @@ -1,3 +1,3 @@ export default { - html: `

1 1

` -}; \ No newline at end of file + html: '

1 1

' +}; diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js new file mode 100644 index 0000000000..a22aa878ff --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js @@ -0,0 +1,9 @@ +// destructure to store value +export default { + skip_if_ssr: true, // pending https://github.com/sveltejs/svelte/issues/3582 + html: '

2 2 xxx 5 6 9 10 2

', + async test({ assert, target, component }) { + await component.update(); + assert.htmlEqual(target.innerHTML, '

11 11 yyy 12 13 14 15 11

'); + } +}; diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/main.svelte b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/main.svelte new file mode 100644 index 0000000000..c1bf63d9cd --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/main.svelte @@ -0,0 +1,29 @@ + + +

{foo} {$eid} {$u.name} {$v} {$w} {$x} {$y} {$z}

diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js new file mode 100644 index 0000000000..6a613f73c4 --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js @@ -0,0 +1,9 @@ +// destructure to store +export default { + html: '

2 2 xxx 5 6 9 10 2

', + skip_if_ssr: true, + async test({ assert, target, component }) { + await component.update(); + assert.htmlEqual(target.innerHTML, '

11 11 yyy 12 13 14 15 11

'); + } +}; diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte new file mode 100644 index 0000000000..cd49223535 --- /dev/null +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/main.svelte @@ -0,0 +1,29 @@ + + +

{foo} {$eid} {u.name} {v} {$w} {$x} {$y} {$z}

diff --git a/test/runtime/samples/reactive-assignment-in-complex-declaration/_config.js b/test/runtime/samples/reactive-assignment-in-complex-declaration/_config.js index d17a81e052..0636620619 100644 --- a/test/runtime/samples/reactive-assignment-in-complex-declaration/_config.js +++ b/test/runtime/samples/reactive-assignment-in-complex-declaration/_config.js @@ -1,3 +1,3 @@ export default { - html: `

2 2

` -}; \ No newline at end of file + html: '

2 2

' +}; diff --git a/test/runtime/samples/reactive-assignment-in-declaration/_config.js b/test/runtime/samples/reactive-assignment-in-declaration/_config.js index f0bf2cdc70..0402f34a2f 100644 --- a/test/runtime/samples/reactive-assignment-in-declaration/_config.js +++ b/test/runtime/samples/reactive-assignment-in-declaration/_config.js @@ -1,3 +1,3 @@ export default { - html: `

1 1

` -}; \ No newline at end of file + html: '

1 1

' +}; diff --git a/test/runtime/samples/reactive-assignment-in-declaration/main.svelte b/test/runtime/samples/reactive-assignment-in-declaration/main.svelte index 8aa05964dd..edac4427bb 100644 --- a/test/runtime/samples/reactive-assignment-in-declaration/main.svelte +++ b/test/runtime/samples/reactive-assignment-in-declaration/main.svelte @@ -1,6 +1,9 @@

{foo} {bar}

diff --git a/test/runtime/samples/reactive-assignment-in-for-loop-head/_config.js b/test/runtime/samples/reactive-assignment-in-for-loop-head/_config.js index df64f577df..8f57423d5c 100644 --- a/test/runtime/samples/reactive-assignment-in-for-loop-head/_config.js +++ b/test/runtime/samples/reactive-assignment-in-for-loop-head/_config.js @@ -1,3 +1,3 @@ export default { - html: `

0 0

` -}; \ No newline at end of file + html: '

0 0

' +}; diff --git a/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte b/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte index 1c24f364ac..b007f6fe8b 100644 --- a/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte +++ b/test/runtime/samples/reactive-assignment-in-for-loop-head/main.svelte @@ -1,9 +1,14 @@

{foo1} {foo2}

diff --git a/test/runtime/samples/reactive-block-break/_config.js b/test/runtime/samples/reactive-block-break/_config.js index f2d3e6a8f5..e00bb9f480 100644 --- a/test/runtime/samples/reactive-block-break/_config.js +++ b/test/runtime/samples/reactive-block-break/_config.js @@ -1,3 +1,3 @@ export default { - html: `

1 2

` -}; \ No newline at end of file + html: '

1 2

' +}; diff --git a/test/runtime/samples/reactive-function-called-reassigned/_config.js b/test/runtime/samples/reactive-function-called-reassigned/_config.js new file mode 100644 index 0000000000..7b2a8b72fe --- /dev/null +++ b/test/runtime/samples/reactive-function-called-reassigned/_config.js @@ -0,0 +1,27 @@ +let value; +let called = 0; +function callback(_value) { + called ++; + value = _value; +} + +export default { + props: { + callback + }, + async test({ assert, component, target, window }) { + assert.equal(called, 1); + + const input = target.querySelector('input'); + + const event = new window.Event('input'); + input.value = 'h'; + await input.dispatchEvent(event); + + assert.equal(called, 2); + assert.equal(value.length, 3); + assert.equal(value[0], 'h'); + assert.equal(value[1], '2'); + assert.equal(value[2], '3'); + } +}; diff --git a/test/runtime/samples/reactive-function-called-reassigned/main.svelte b/test/runtime/samples/reactive-function-called-reassigned/main.svelte new file mode 100644 index 0000000000..10a3c79d14 --- /dev/null +++ b/test/runtime/samples/reactive-function-called-reassigned/main.svelte @@ -0,0 +1,10 @@ + + +{#each refs as ref} + +{/each} \ No newline at end of file diff --git a/test/runtime/samples/reactive-import-statement-2/_config.js b/test/runtime/samples/reactive-import-statement-2/_config.js new file mode 100644 index 0000000000..fc6d8f008d --- /dev/null +++ b/test/runtime/samples/reactive-import-statement-2/_config.js @@ -0,0 +1,3 @@ +export default { + html: '

prop value

' +}; diff --git a/test/runtime/samples/reactive-import-statement-2/data.js b/test/runtime/samples/reactive-import-statement-2/data.js new file mode 100644 index 0000000000..56fb86982c --- /dev/null +++ b/test/runtime/samples/reactive-import-statement-2/data.js @@ -0,0 +1,3 @@ +export const obj = { + prop: 'prop value' +}; diff --git a/test/runtime/samples/reactive-import-statement-2/main.svelte b/test/runtime/samples/reactive-import-statement-2/main.svelte new file mode 100644 index 0000000000..2582974b71 --- /dev/null +++ b/test/runtime/samples/reactive-import-statement-2/main.svelte @@ -0,0 +1,8 @@ + + +

{prop}

diff --git a/test/runtime/samples/reactive-import-statement/_config.js b/test/runtime/samples/reactive-import-statement/_config.js new file mode 100644 index 0000000000..45a844afa0 --- /dev/null +++ b/test/runtime/samples/reactive-import-statement/_config.js @@ -0,0 +1,38 @@ +import * as path from 'path'; + +export default { + html: ` + import +

1 + 2 + 3 + 4 = 10

+ local +

1 + 2 + 3 + 4 = 10

+ + `, + before_test() { + delete require.cache[path.resolve(__dirname, 'data.js')]; + }, + async test({ assert, target, window }) { + const btn = target.querySelector('button'); + const clickEvent = new window.MouseEvent('click'); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual(target.innerHTML, ` + import +

1 + 2 + 3 + 4 + 5 = 15

+ local +

1 + 2 + 3 + 4 + 5 = 15

+ + `); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual(target.innerHTML, ` + import +

1 + 2 + 3 + 4 + 5 + 6 = 21

+ local +

1 + 2 + 3 + 4 + 5 + 6 = 21

+ + `); + } +}; diff --git a/test/runtime/samples/reactive-import-statement/data.js b/test/runtime/samples/reactive-import-statement/data.js new file mode 100644 index 0000000000..22f2f374ab --- /dev/null +++ b/test/runtime/samples/reactive-import-statement/data.js @@ -0,0 +1 @@ +export const numbers = [1, 2, 3, 4]; diff --git a/test/runtime/samples/reactive-import-statement/main.svelte b/test/runtime/samples/reactive-import-statement/main.svelte new file mode 100644 index 0000000000..daded0494f --- /dev/null +++ b/test/runtime/samples/reactive-import-statement/main.svelte @@ -0,0 +1,19 @@ + + +import

{numbers.join(' + ')} = {sum}

+local

{local_numbers.join(' + ')} = {local_sum}

+ + \ No newline at end of file diff --git a/test/runtime/samples/reactive-value-assign-property/_config.js b/test/runtime/samples/reactive-value-assign-property/_config.js new file mode 100644 index 0000000000..b6d8bf51be --- /dev/null +++ b/test/runtime/samples/reactive-value-assign-property/_config.js @@ -0,0 +1,5 @@ +export default { + html: ` +

Hello world!

+ ` +}; diff --git a/test/runtime/samples/reactive-value-assign-property/main.svelte b/test/runtime/samples/reactive-value-assign-property/main.svelte new file mode 100644 index 0000000000..58e0fdb03c --- /dev/null +++ b/test/runtime/samples/reactive-value-assign-property/main.svelte @@ -0,0 +1,6 @@ + + +

Hello {user.name}!

\ No newline at end of file diff --git a/test/runtime/samples/reactive-value-coerce/_config.js b/test/runtime/samples/reactive-value-coerce/_config.js index 7d8bcb6b50..9cf9d7d8ee 100644 --- a/test/runtime/samples/reactive-value-coerce/_config.js +++ b/test/runtime/samples/reactive-value-coerce/_config.js @@ -1,10 +1,10 @@ export default { - html: `1-1`, + html: '1-1', test: ({ assert, component, target }) => { component.a.b[0] = 2; component.a = component.a; // eslint-disable-line no-self-assign - assert.htmlEqual(target.innerHTML, `2-2`); + assert.htmlEqual(target.innerHTML, '2-2'); } }; diff --git a/test/runtime/samples/reactive-value-function/_config.js b/test/runtime/samples/reactive-value-function/_config.js index c2de1af713..2a84953576 100644 --- a/test/runtime/samples/reactive-value-function/_config.js +++ b/test/runtime/samples/reactive-value-function/_config.js @@ -1,9 +1,9 @@ export default { - html: `1-2`, + html: '1-2', async test({ assert, component, target }) { await component.update(); - assert.htmlEqual(target.innerHTML, `3-4`); + assert.htmlEqual(target.innerHTML, '3-4'); } }; diff --git a/test/runtime/samples/reactive-value-mutate/_config.js b/test/runtime/samples/reactive-value-mutate/_config.js index e408816834..66979f1e31 100644 --- a/test/runtime/samples/reactive-value-mutate/_config.js +++ b/test/runtime/samples/reactive-value-mutate/_config.js @@ -1,3 +1,3 @@ export default { - html: `{"bar":42}` + html: '{"bar":42}' }; diff --git a/test/runtime/samples/script-style-non-top-level/_config.js b/test/runtime/samples/script-style-non-top-level/_config.js index 86eddf4611..22186b345d 100644 --- a/test/runtime/samples/script-style-non-top-level/_config.js +++ b/test/runtime/samples/script-style-non-top-level/_config.js @@ -5,4 +5,4 @@ export default { ` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/select-no-whitespace/_config.js b/test/runtime/samples/select-no-whitespace/_config.js index 7388527849..fbd4990317 100644 --- a/test/runtime/samples/select-no-whitespace/_config.js +++ b/test/runtime/samples/select-no-whitespace/_config.js @@ -3,4 +3,4 @@ export default { const select = target.querySelector( 'select' ); assert.equal( select.childNodes.length, 3 ); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/self-reference-component/_config.js b/test/runtime/samples/self-reference-component/_config.js index e3e0ad3a4f..c3456b59c2 100644 --- a/test/runtime/samples/self-reference-component/_config.js +++ b/test/runtime/samples/self-reference-component/_config.js @@ -1,3 +1,3 @@ export default { - html: '5 4 3 2 1 0', -}; \ No newline at end of file + html: '5 4 3 2 1 0' +}; diff --git a/test/runtime/samples/self-reference-tree/_config.js b/test/runtime/samples/self-reference-tree/_config.js index 581f03eade..cfa7528d31 100644 --- a/test/runtime/samples/self-reference-tree/_config.js +++ b/test/runtime/samples/self-reference-tree/_config.js @@ -62,4 +62,4 @@ export default { ` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/self-reference/_config.js b/test/runtime/samples/self-reference/_config.js index 69be606bbe..1bcb660621 100644 --- a/test/runtime/samples/self-reference/_config.js +++ b/test/runtime/samples/self-reference/_config.js @@ -11,4 +11,4 @@ export default { 1 0 ` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/semicolon-hoisting/_config.js b/test/runtime/samples/semicolon-hoisting/_config.js index 88d81cdc9e..22dc25b41e 100644 --- a/test/runtime/samples/semicolon-hoisting/_config.js +++ b/test/runtime/samples/semicolon-hoisting/_config.js @@ -1,3 +1,3 @@ export default { - html: `` -}; \ No newline at end of file + html: '' +}; diff --git a/test/runtime/samples/set-after-destroy/_config.js b/test/runtime/samples/set-after-destroy/_config.js index 9d79329546..063c133b87 100644 --- a/test/runtime/samples/set-after-destroy/_config.js +++ b/test/runtime/samples/set-after-destroy/_config.js @@ -7,4 +7,4 @@ export default { component.$destroy(); component.x = 2; } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/set-null-text-node/_config.js b/test/runtime/samples/set-null-text-node/_config.js index 6bc775f3b7..a106ee9069 100644 --- a/test/runtime/samples/set-null-text-node/_config.js +++ b/test/runtime/samples/set-null-text-node/_config.js @@ -10,4 +10,4 @@ export default { component.foo = null; assert.htmlEqual(target.innerHTML, 'foo is null'); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/set-undefined-attr/_config.js b/test/runtime/samples/set-undefined-attr/_config.js index b23f51dfc9..49c4216e57 100644 --- a/test/runtime/samples/set-undefined-attr/_config.js +++ b/test/runtime/samples/set-undefined-attr/_config.js @@ -1,5 +1,5 @@ export default { - html: `
`, + html: "
", - ssrHtml: `
`, + ssrHtml: "
" }; diff --git a/test/runtime/samples/shorthand-method-in-template/_config.js b/test/runtime/samples/shorthand-method-in-template/_config.js index ddd282644d..b097a46716 100644 --- a/test/runtime/samples/shorthand-method-in-template/_config.js +++ b/test/runtime/samples/shorthand-method-in-template/_config.js @@ -1,3 +1,3 @@ export default { html: '42' -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/sigil-component-prop/_config.js b/test/runtime/samples/sigil-component-prop/_config.js index 2f467bb9d4..105f8b468c 100644 --- a/test/runtime/samples/sigil-component-prop/_config.js +++ b/test/runtime/samples/sigil-component-prop/_config.js @@ -3,5 +3,5 @@ export default { dev: true }, props: { foo: 'foo' }, - html: `
foo @ foo # foo
`, + html: '
foo @ foo # foo
' }; diff --git a/test/runtime/samples/sigil-expression-function-body/_config.js b/test/runtime/samples/sigil-expression-function-body/_config.js index fccd0db2d0..8d88d1fd08 100644 --- a/test/runtime/samples/sigil-expression-function-body/_config.js +++ b/test/runtime/samples/sigil-expression-function-body/_config.js @@ -1,3 +1,3 @@ export default { - html: `@foo` + html: '@foo' }; diff --git a/test/runtime/samples/sigil-static-#/_config.js b/test/runtime/samples/sigil-static-#/_config.js index 747ddc2a94..3bf2601f70 100644 --- a/test/runtime/samples/sigil-static-#/_config.js +++ b/test/runtime/samples/sigil-static-#/_config.js @@ -1,3 +1,3 @@ export default { - html: `#foo` -}; \ No newline at end of file + html: '#foo' +}; diff --git a/test/runtime/samples/sigil-static-@/_config.js b/test/runtime/samples/sigil-static-@/_config.js index ada3a602ab..8d88d1fd08 100644 --- a/test/runtime/samples/sigil-static-@/_config.js +++ b/test/runtime/samples/sigil-static-@/_config.js @@ -1,3 +1,3 @@ export default { - html: `@foo` -}; \ No newline at end of file + html: '@foo' +}; diff --git a/test/runtime/samples/slot-if-block-update-no-anchor/_config.js b/test/runtime/samples/slot-if-block-update-no-anchor/_config.js new file mode 100644 index 0000000000..f05d79c265 --- /dev/null +++ b/test/runtime/samples/slot-if-block-update-no-anchor/_config.js @@ -0,0 +1,7 @@ +export default { + test({ assert, target, component }) { + assert.htmlEqual(target.innerHTML, ''); + component.enabled = true; + assert.htmlEqual(target.innerHTML, 'enabled'); + } +}; diff --git a/test/runtime/samples/slot-if-block-update-no-anchor/main.svelte b/test/runtime/samples/slot-if-block-update-no-anchor/main.svelte new file mode 100644 index 0000000000..7960f35bc9 --- /dev/null +++ b/test/runtime/samples/slot-if-block-update-no-anchor/main.svelte @@ -0,0 +1,9 @@ + + + + + {#if enabled}enabled{/if} + + diff --git a/test/runtime/samples/slot-in-custom-element/_config.js b/test/runtime/samples/slot-in-custom-element/_config.js index f17cc9adcb..a0b97ec6d0 100644 --- a/test/runtime/samples/slot-in-custom-element/_config.js +++ b/test/runtime/samples/slot-in-custom-element/_config.js @@ -4,4 +4,4 @@ export default {
header header header
` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/spread-component-2/_config.js b/test/runtime/samples/spread-component-2/_config.js index 6d36e8e60d..e5441bc4b9 100644 --- a/test/runtime/samples/spread-component-2/_config.js +++ b/test/runtime/samples/spread-component-2/_config.js @@ -10,7 +10,7 @@ export default { baz: 50 + 2, qux: 1, quux: 'quuxx' - }], + }] }, html: ` diff --git a/test/runtime/samples/spread-component-dynamic-non-object-multiple-dependencies/_config.js b/test/runtime/samples/spread-component-dynamic-non-object-multiple-dependencies/_config.js index c5e23a023c..d7ad47b01f 100644 --- a/test/runtime/samples/spread-component-dynamic-non-object-multiple-dependencies/_config.js +++ b/test/runtime/samples/spread-component-dynamic-non-object-multiple-dependencies/_config.js @@ -2,7 +2,7 @@ export default { props: { props: { foo: 'lol', - baz: 40 + 2, + baz: 40 + 2 } }, diff --git a/test/runtime/samples/spread-component-dynamic-non-object/_config.js b/test/runtime/samples/spread-component-dynamic-non-object/_config.js index 094f2fbb9b..fa8de8ad94 100644 --- a/test/runtime/samples/spread-component-dynamic-non-object/_config.js +++ b/test/runtime/samples/spread-component-dynamic-non-object/_config.js @@ -2,7 +2,7 @@ export default { props: { props: { foo: 'lol', - baz: 40 + 2, + baz: 40 + 2 } }, diff --git a/test/runtime/samples/spread-component-dynamic-undefined/_config.js b/test/runtime/samples/spread-component-dynamic-undefined/_config.js index 09e5f87c14..ba41df3e54 100644 --- a/test/runtime/samples/spread-component-dynamic-undefined/_config.js +++ b/test/runtime/samples/spread-component-dynamic-undefined/_config.js @@ -1,17 +1,17 @@ export default { props: { props: { - a: 1, - }, + a: 1 + } }, - html: ``, + html: '', test({ assert, component, target }) { component.props = { - a: 2, + a: 2 }; - assert.htmlEqual(target.innerHTML, ``); - }, + assert.htmlEqual(target.innerHTML, ''); + } }; diff --git a/test/runtime/samples/spread-component-dynamic/_config.js b/test/runtime/samples/spread-component-dynamic/_config.js index a6bf952ae0..7992a30514 100644 --- a/test/runtime/samples/spread-component-dynamic/_config.js +++ b/test/runtime/samples/spread-component-dynamic/_config.js @@ -1,8 +1,8 @@ export default { props: { props: { - a: 1, - }, + a: 1 + } }, html: ` @@ -11,9 +11,9 @@ export default { test({ assert, component, target }) { component.props = { - a: 2, + a: 2 }; - assert.htmlEqual(target.innerHTML, `

a: 2

`); - }, + assert.htmlEqual(target.innerHTML, '

a: 2

'); + } }; diff --git a/test/runtime/samples/spread-component-multiple-dependencies/_config.js b/test/runtime/samples/spread-component-multiple-dependencies/_config.js index bc05f31130..ee2c0feda8 100644 --- a/test/runtime/samples/spread-component-multiple-dependencies/_config.js +++ b/test/runtime/samples/spread-component-multiple-dependencies/_config.js @@ -1,10 +1,10 @@ export default { - html: `b baz`, + html: 'b baz', test({ assert, component, target }) { component.foo = true; assert.htmlEqual( target.innerHTML, - `a baz` + 'a baz' ); - }, + } }; diff --git a/test/runtime/samples/spread-each-component/_config.js b/test/runtime/samples/spread-each-component/_config.js index bc4d8ee7a4..66d2381875 100644 --- a/test/runtime/samples/spread-each-component/_config.js +++ b/test/runtime/samples/spread-each-component/_config.js @@ -20,5 +20,5 @@ export default {
`); - }, + } }; diff --git a/test/runtime/samples/spread-each-element/_config.js b/test/runtime/samples/spread-each-element/_config.js index 5dbd82a892..579f840099 100644 --- a/test/runtime/samples/spread-each-element/_config.js +++ b/test/runtime/samples/spread-each-element/_config.js @@ -20,5 +20,5 @@ export default {
`); - }, + } }; diff --git a/test/runtime/samples/spread-element-boolean/_config.js b/test/runtime/samples/spread-element-boolean/_config.js index 3ee277eec4..3ceeb3f677 100644 --- a/test/runtime/samples/spread-element-boolean/_config.js +++ b/test/runtime/samples/spread-element-boolean/_config.js @@ -18,8 +18,8 @@ export default { assert.htmlEqual( target.innerHTML, - `` + '' ); assert.ok(!button.disabled); - }, + } }; diff --git a/test/runtime/samples/spread-element-class/_config.js b/test/runtime/samples/spread-element-class/_config.js index 7fc3d49012..b699848210 100644 --- a/test/runtime/samples/spread-element-class/_config.js +++ b/test/runtime/samples/spread-element-class/_config.js @@ -1,7 +1,7 @@ export default { - html: `
hello
`, + html: "
hello
", test({ assert, component, target }) { component.blah = 'goodbye'; - assert.htmlEqual(target.innerHTML, `
goodbye
`); + assert.htmlEqual(target.innerHTML, "
goodbye
"); } }; diff --git a/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js b/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js new file mode 100644 index 0000000000..4bbc9d278c --- /dev/null +++ b/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js @@ -0,0 +1,15 @@ +export default { + props: { + props: { + 'data-foo': 'bar' + } + }, + + html: '', + + async test({ assert, component, target, window }) { + const input = target.querySelector('input'); + assert.equal(input.value, 'abc'); + assert.equal(input.__value, 'abc'); + } +}; diff --git a/test/runtime/samples/spread-element-input-bind-group-with-value-attr/main.svelte b/test/runtime/samples/spread-element-input-bind-group-with-value-attr/main.svelte new file mode 100644 index 0000000000..ce6b76f093 --- /dev/null +++ b/test/runtime/samples/spread-element-input-bind-group-with-value-attr/main.svelte @@ -0,0 +1,6 @@ + + + diff --git a/test/runtime/samples/spread-element-input-select-multiple/_config.js b/test/runtime/samples/spread-element-input-select-multiple/_config.js new file mode 100644 index 0000000000..1ddcd9eb6d --- /dev/null +++ b/test/runtime/samples/spread-element-input-select-multiple/_config.js @@ -0,0 +1,39 @@ +export default { + async test({ assert, component, target, window }) { + const [input1, input2] = target.querySelectorAll('input'); + const select = target.querySelector('select'); + const [option1, option2] = select.childNodes; + + let selections = Array.from(select.selectedOptions); + assert.equal(selections.length, 2); + assert.ok(selections.includes(option1)); + assert.ok(selections.includes(option2)); + + const event = new window.Event('change'); + + input1.checked = false; + await input1.dispatchEvent(event); + + selections = Array.from(select.selectedOptions); + assert.equal(selections.length, 1); + assert.ok(!selections.includes(option1)); + assert.ok(selections.includes(option2)); + + input2.checked = false; + await input2.dispatchEvent(event); + input1.checked = true; + await input1.dispatchEvent(event); + + selections = Array.from(select.selectedOptions); + assert.equal(selections.length, 1); + assert.ok(selections.includes(option1)); + assert.ok(!selections.includes(option2)); + + component.spread = { value: ['Hello', 'World'] }; + + selections = Array.from(select.selectedOptions); + assert.equal(selections.length, 2); + assert.ok(selections.includes(option1)); + assert.ok(selections.includes(option2)); + } +}; diff --git a/test/runtime/samples/spread-element-input-select-multiple/main.svelte b/test/runtime/samples/spread-element-input-select-multiple/main.svelte new file mode 100644 index 0000000000..d2fb12dd20 --- /dev/null +++ b/test/runtime/samples/spread-element-input-select-multiple/main.svelte @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/test/runtime/samples/spread-element-input-value-undefined/_config.js b/test/runtime/samples/spread-element-input-value-undefined/_config.js new file mode 100644 index 0000000000..9a83dccd80 --- /dev/null +++ b/test/runtime/samples/spread-element-input-value-undefined/_config.js @@ -0,0 +1,12 @@ +export default { + async test({ assert, component, target, window }) { + const input = target.querySelector('input'); + component.value = undefined; + + assert.equal(input.value, 'undefined'); + + component.value = 'foobar'; + + assert.equal(input.value, 'foobar'); + } +}; diff --git a/test/runtime/samples/spread-element-input-value-undefined/main.svelte b/test/runtime/samples/spread-element-input-value-undefined/main.svelte new file mode 100644 index 0000000000..5c9121dc03 --- /dev/null +++ b/test/runtime/samples/spread-element-input-value-undefined/main.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/test/runtime/samples/spread-element-input-value/InputOne.svelte b/test/runtime/samples/spread-element-input-value/InputOne.svelte new file mode 100644 index 0000000000..92ecb7b9a9 --- /dev/null +++ b/test/runtime/samples/spread-element-input-value/InputOne.svelte @@ -0,0 +1,18 @@ + + + diff --git a/test/runtime/samples/spread-element-input-value/InputTwo.svelte b/test/runtime/samples/spread-element-input-value/InputTwo.svelte new file mode 100644 index 0000000000..33ec0622a4 --- /dev/null +++ b/test/runtime/samples/spread-element-input-value/InputTwo.svelte @@ -0,0 +1,19 @@ + + + diff --git a/test/runtime/samples/spread-element-input-value/_config.js b/test/runtime/samples/spread-element-input-value/_config.js new file mode 100644 index 0000000000..0df088159a --- /dev/null +++ b/test/runtime/samples/spread-element-input-value/_config.js @@ -0,0 +1,62 @@ +export default { + async test({ assert, component, target, window }) { + const [input1, input2] = target.querySelectorAll('input'); + + // we are not able emulate user interaction in jsdom, + // therefore, jsdom could not validate minlength / maxlength + + // we simulate user input with + // setting input.value + dispathEvent + + // and we determine if svelte does not set the `input.value` again by + // spying on the setter of `input.value` + + const spy1 = spyOnValueSetter(input1, input1.value); + const spy2 = spyOnValueSetter(input2, input2.value); + + const event = new window.Event('input'); + + input1.value = '12345'; + spy1.reset(); + await input1.dispatchEvent(event); + + assert.ok(!spy1.isSetCalled()); + + input2.value = '12345'; + spy2.reset(); + await input2.dispatchEvent(event); + + assert.ok(!spy2.isSetCalled()); + + spy1.reset(); + component.val1 = '56789'; + assert.ok(spy1.isSetCalled()); + + spy2.reset(); + component.val2 = '56789'; + assert.ok(spy2.isSetCalled()); + } +}; + +function spyOnValueSetter(input, initialValue) { + let value = initialValue; + let isSet = false; + Object.defineProperty(input, 'value', { + get() { + return value; + }, + set(_value) { + value = _value; + isSet = true; + } + }); + + return { + isSetCalled() { + return isSet; + }, + reset() { + isSet = false; + } + }; +} diff --git a/test/runtime/samples/spread-element-input-value/main.svelte b/test/runtime/samples/spread-element-input-value/main.svelte new file mode 100644 index 0000000000..bb5f0e00bf --- /dev/null +++ b/test/runtime/samples/spread-element-input-value/main.svelte @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/test/runtime/samples/spread-element-input-value/utils.js b/test/runtime/samples/spread-element-input-value/utils.js new file mode 100644 index 0000000000..ee941bda55 --- /dev/null +++ b/test/runtime/samples/spread-element-input-value/utils.js @@ -0,0 +1,6 @@ +export function omit(obj, ...keysToOmit) { + return Object.keys(obj).reduce((acc, key) => { + if (keysToOmit.indexOf(key) === -1) acc[key] = obj[key]; + return acc; + }, {}); +} diff --git a/test/runtime/samples/spread-element-input/_config.js b/test/runtime/samples/spread-element-input/_config.js index 80685b9d20..2e68e9832f 100644 --- a/test/runtime/samples/spread-element-input/_config.js +++ b/test/runtime/samples/spread-element-input/_config.js @@ -5,5 +5,5 @@ export default { } }, - html: `` + html: '' }; diff --git a/test/runtime/samples/spread-element-multiple-dependencies/_config.js b/test/runtime/samples/spread-element-multiple-dependencies/_config.js index 69ef1f8ebe..6183e6bf6e 100644 --- a/test/runtime/samples/spread-element-multiple-dependencies/_config.js +++ b/test/runtime/samples/spread-element-multiple-dependencies/_config.js @@ -1,10 +1,10 @@ export default { - html: `
`, + html: "
", test({ assert, component, target }) { component.foo = true; assert.htmlEqual( target.innerHTML, - `
` + "
" ); - }, + } }; diff --git a/test/runtime/samples/spread-element-multiple/_config.js b/test/runtime/samples/spread-element-multiple/_config.js index 641f74d727..38afe2fe8e 100644 --- a/test/runtime/samples/spread-element-multiple/_config.js +++ b/test/runtime/samples/spread-element-multiple/_config.js @@ -2,12 +2,12 @@ export default { props: { a: { 'data-one': 1, - 'data-two': 2, + 'data-two': 2 }, c: { - 'data-b': 'overridden', + 'data-b': 'overridden' }, - d: 'deeeeee', + d: 'deeeeee' }, html: ` @@ -25,7 +25,7 @@ export default { assert.htmlEqual( target.innerHTML, - `
test
` + '
test
' ); - }, + } }; diff --git a/test/runtime/samples/spread-element-readonly/_config.js b/test/runtime/samples/spread-element-readonly/_config.js index 1d349fd76f..5e33acb0aa 100644 --- a/test/runtime/samples/spread-element-readonly/_config.js +++ b/test/runtime/samples/spread-element-readonly/_config.js @@ -1,6 +1,6 @@ export default { skip_if_ssr: true, // DOM and SSR output is different, a separate SSR test exists - html: ``, + html: '', test({ assert, target }) { const div = target.querySelector('input'); diff --git a/test/runtime/samples/spread-element-removal/_config.js b/test/runtime/samples/spread-element-removal/_config.js index 270804170d..1fd2443369 100644 --- a/test/runtime/samples/spread-element-removal/_config.js +++ b/test/runtime/samples/spread-element-removal/_config.js @@ -1,3 +1,3 @@ export default { - html: `` + html: '' }; diff --git a/test/runtime/samples/spread-element/_config.js b/test/runtime/samples/spread-element/_config.js index 0763634b0f..2332891b67 100644 --- a/test/runtime/samples/spread-element/_config.js +++ b/test/runtime/samples/spread-element/_config.js @@ -1,5 +1,5 @@ export default { - html: `
red
`, + html: '
red
', test({ assert, component, target }) { const div = target.querySelector( 'div' ); @@ -9,13 +9,13 @@ export default { component.color = 'blue'; component.props = { 'data-foo': 'baz', 'data-named': 'qux' }; - assert.htmlEqual( target.innerHTML, `
blue
` ); + assert.htmlEqual( target.innerHTML, '
blue
' ); assert.equal( div.dataset.foo, 'baz' ); assert.equal( div.dataset.named, 'value' ); component.color = 'blue'; component.props = {}; - assert.htmlEqual( target.innerHTML, `
blue
` ); + assert.htmlEqual( target.innerHTML, '
blue
' ); assert.equal( div.dataset.foo, undefined ); } }; diff --git a/test/runtime/samples/spring/_config.js b/test/runtime/samples/spring/_config.js index 49367ce08b..5fd33b2e51 100644 --- a/test/runtime/samples/spring/_config.js +++ b/test/runtime/samples/spring/_config.js @@ -1,3 +1,3 @@ export default { - html: `

0

` + html: '

0

' }; diff --git a/test/runtime/samples/state-deconflicted/_config.js b/test/runtime/samples/state-deconflicted/_config.js index 3258754400..ff1b10b481 100644 --- a/test/runtime/samples/state-deconflicted/_config.js +++ b/test/runtime/samples/state-deconflicted/_config.js @@ -49,4 +49,4 @@ export default { ` ); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-assignment-updates-property/_config.js b/test/runtime/samples/store-assignment-updates-property/_config.js new file mode 100644 index 0000000000..168f7d27a0 --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-property/_config.js @@ -0,0 +1,32 @@ +export default { + html: ` +

a: {"foo":3,"bar":2}

+

b: {"foo":3}

+ + + `, + skip_if_ssr: true, + + async test({ assert, component, target, window }) { + const [btn1, btn2] = target.querySelectorAll('button'); + const click = new window.MouseEvent('click'); + + await btn1.dispatchEvent(click); + + assert.htmlEqual(target.innerHTML, ` +

a: {"foo":4,"bar":2}

+

b: {"foo":4,"baz":0}

+ + + `); + + await btn2.dispatchEvent(click); + + assert.htmlEqual(target.innerHTML, ` +

a: {"foo":5,"bar":2}

+

b: {"foo":5,"qux":0}

+ + + `); + } +}; diff --git a/test/runtime/samples/store-assignment-updates-property/main.svelte b/test/runtime/samples/store-assignment-updates-property/main.svelte new file mode 100644 index 0000000000..c3196a278c --- /dev/null +++ b/test/runtime/samples/store-assignment-updates-property/main.svelte @@ -0,0 +1,24 @@ + + +

a: {JSON.stringify($a)}

+

b: {JSON.stringify($b)}

+ + `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-assignment-updates/_config.js b/test/runtime/samples/store-assignment-updates/_config.js index 1b36d92863..c4a09a978e 100644 --- a/test/runtime/samples/store-assignment-updates/_config.js +++ b/test/runtime/samples/store-assignment-updates/_config.js @@ -28,4 +28,4 @@ export default {

doubled: 84

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-event-callback/_config.js b/test/runtime/samples/store-auto-subscribe-event-callback/_config.js index 747ed3e4ad..7897036809 100644 --- a/test/runtime/samples/store-auto-subscribe-event-callback/_config.js +++ b/test/runtime/samples/store-auto-subscribe-event-callback/_config.js @@ -18,5 +18,5 @@ export default { Dirty: true Valid: true `); - }, + } }; diff --git a/test/runtime/samples/store-auto-subscribe-immediate-multiple-vars/_config.js b/test/runtime/samples/store-auto-subscribe-immediate-multiple-vars/_config.js index 9cfd765cde..fdaa951666 100644 --- a/test/runtime/samples/store-auto-subscribe-immediate-multiple-vars/_config.js +++ b/test/runtime/samples/store-auto-subscribe-immediate-multiple-vars/_config.js @@ -6,4 +6,4 @@ export default { async test({ assert, component }) { assert.equal(component.initial_foo, 42); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-immediate/_config.js b/test/runtime/samples/store-auto-subscribe-immediate/_config.js index 9cfd765cde..fdaa951666 100644 --- a/test/runtime/samples/store-auto-subscribe-immediate/_config.js +++ b/test/runtime/samples/store-auto-subscribe-immediate/_config.js @@ -6,4 +6,4 @@ export default { async test({ assert, component }) { assert.equal(component.initial_foo, 42); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-implicit/_config.js b/test/runtime/samples/store-auto-subscribe-implicit/_config.js index eca1f314ff..f132901bf0 100644 --- a/test/runtime/samples/store-auto-subscribe-implicit/_config.js +++ b/test/runtime/samples/store-auto-subscribe-implicit/_config.js @@ -25,4 +25,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-in-each/_config.js b/test/runtime/samples/store-auto-subscribe-in-each/_config.js index a49dbab85c..8c8fa001d8 100644 --- a/test/runtime/samples/store-auto-subscribe-in-each/_config.js +++ b/test/runtime/samples/store-auto-subscribe-in-each/_config.js @@ -37,4 +37,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-in-reactive-declaration/_config.js b/test/runtime/samples/store-auto-subscribe-in-reactive-declaration/_config.js index 2240425d91..cf1bdce68a 100644 --- a/test/runtime/samples/store-auto-subscribe-in-reactive-declaration/_config.js +++ b/test/runtime/samples/store-auto-subscribe-in-reactive-declaration/_config.js @@ -25,4 +25,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-in-script/_config.js b/test/runtime/samples/store-auto-subscribe-in-script/_config.js index cfd4475240..7ea7eac87b 100644 --- a/test/runtime/samples/store-auto-subscribe-in-script/_config.js +++ b/test/runtime/samples/store-auto-subscribe-in-script/_config.js @@ -23,4 +23,4 @@ export default { await count.set(42); assert.equal(component.get_count(), 42); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-missing-global-script/_config.js b/test/runtime/samples/store-auto-subscribe-missing-global-script/_config.js index c4eb72b553..f3df26c0de 100644 --- a/test/runtime/samples/store-auto-subscribe-missing-global-script/_config.js +++ b/test/runtime/samples/store-auto-subscribe-missing-global-script/_config.js @@ -1,3 +1,3 @@ export default { error: 'missingGlobal is not defined' -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe-missing-global-template/_config.js b/test/runtime/samples/store-auto-subscribe-missing-global-template/_config.js index c4eb72b553..f3df26c0de 100644 --- a/test/runtime/samples/store-auto-subscribe-missing-global-template/_config.js +++ b/test/runtime/samples/store-auto-subscribe-missing-global-template/_config.js @@ -1,3 +1,3 @@ export default { error: 'missingGlobal is not defined' -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-auto-subscribe/_config.js b/test/runtime/samples/store-auto-subscribe/_config.js index eca1f314ff..f132901bf0 100644 --- a/test/runtime/samples/store-auto-subscribe/_config.js +++ b/test/runtime/samples/store-auto-subscribe/_config.js @@ -25,4 +25,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-contextual/_config.js b/test/runtime/samples/store-contextual/_config.js index e06332a233..2a4f8fef8d 100644 --- a/test/runtime/samples/store-contextual/_config.js +++ b/test/runtime/samples/store-contextual/_config.js @@ -7,7 +7,7 @@ const todos = [ ]; export default { - error: `Stores must be declared at the top level of the component (this may change in a future version of Svelte)`, + error: 'Stores must be declared at the top level of the component (this may change in a future version of Svelte)', props: { todos @@ -73,4 +73,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-dev-mode-error/_config.js b/test/runtime/samples/store-dev-mode-error/_config.js index 70b24337fd..74f4189c36 100644 --- a/test/runtime/samples/store-dev-mode-error/_config.js +++ b/test/runtime/samples/store-dev-mode-error/_config.js @@ -7,5 +7,5 @@ export default { count: 0 }, - error: `'count' is not a store with a 'subscribe' method` -}; \ No newline at end of file + error: "'count' is not a store with a 'subscribe' method" +}; diff --git a/test/runtime/samples/store-each-binding-deep/_config.js b/test/runtime/samples/store-each-binding-deep/_config.js new file mode 100644 index 0000000000..c5f2402ae2 --- /dev/null +++ b/test/runtime/samples/store-each-binding-deep/_config.js @@ -0,0 +1,14 @@ +export default { + async test({ assert, target, window }) { + const input = target.querySelector('input'); + + const event = new window.Event('input'); + input.value = 'changed'; + await input.dispatchEvent(event); + + assert.htmlEqual(target.innerHTML, ` + +

changed

+ `); + } +}; diff --git a/test/runtime/samples/store-each-binding-deep/main.svelte b/test/runtime/samples/store-each-binding-deep/main.svelte new file mode 100644 index 0000000000..8f1cabf5b8 --- /dev/null +++ b/test/runtime/samples/store-each-binding-deep/main.svelte @@ -0,0 +1,11 @@ + + +{#each $itemStore.prop.things as thing } + +{/each} + +

{$itemStore.prop.things[0].name}

\ No newline at end of file diff --git a/test/runtime/samples/store-each-binding-destructuring/_config.js b/test/runtime/samples/store-each-binding-destructuring/_config.js index 70776940dd..c5f2402ae2 100644 --- a/test/runtime/samples/store-each-binding-destructuring/_config.js +++ b/test/runtime/samples/store-each-binding-destructuring/_config.js @@ -11,4 +11,4 @@ export default {

changed

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-each-binding/_config.js b/test/runtime/samples/store-each-binding/_config.js index 70776940dd..c5f2402ae2 100644 --- a/test/runtime/samples/store-each-binding/_config.js +++ b/test/runtime/samples/store-each-binding/_config.js @@ -11,4 +11,4 @@ export default {

changed

`); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-imported-module-b/_config.js b/test/runtime/samples/store-imported-module-b/_config.js index 8f75dcc493..f3c168e4c1 100644 --- a/test/runtime/samples/store-imported-module-b/_config.js +++ b/test/runtime/samples/store-imported-module-b/_config.js @@ -1,3 +1,3 @@ export default { - error: `Cannot reference store value inside + +

{answer}

diff --git a/test/runtime/samples/store-increment-updates-reactive/_config.js b/test/runtime/samples/store-increment-updates-reactive/_config.js index f919d724f8..04bf79d3a3 100644 --- a/test/runtime/samples/store-increment-updates-reactive/_config.js +++ b/test/runtime/samples/store-increment-updates-reactive/_config.js @@ -1,8 +1,8 @@ export default { - html: `0`, + html: '0', async test({ assert, component, target }) { await component.increment(); - assert.htmlEqual(target.innerHTML, `1`); + assert.htmlEqual(target.innerHTML, '1'); } }; diff --git a/test/runtime/samples/store-invalidation-while-update-1/_config.js b/test/runtime/samples/store-invalidation-while-update-1/_config.js index 0c187e97df..9a8237d19d 100644 --- a/test/runtime/samples/store-invalidation-while-update-1/_config.js +++ b/test/runtime/samples/store-invalidation-while-update-1/_config.js @@ -48,4 +48,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-invalidation-while-update-2/_config.js b/test/runtime/samples/store-invalidation-while-update-2/_config.js index aaa7e28333..3f63ebaec7 100644 --- a/test/runtime/samples/store-invalidation-while-update-2/_config.js +++ b/test/runtime/samples/store-invalidation-while-update-2/_config.js @@ -48,4 +48,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-prevent-user-declarations/_config.js b/test/runtime/samples/store-prevent-user-declarations/_config.js index ec099380e8..d79ced4e38 100644 --- a/test/runtime/samples/store-prevent-user-declarations/_config.js +++ b/test/runtime/samples/store-prevent-user-declarations/_config.js @@ -5,5 +5,5 @@ export default { count: writable(0) }, - error: `The $ prefix is reserved, and cannot be used for variable and import names` -}; \ No newline at end of file + error: 'The $ prefix is reserved, and cannot be used for variable and import names' +}; diff --git a/test/runtime/samples/store-resubscribe-b/_config.js b/test/runtime/samples/store-resubscribe-b/_config.js index d043bbcd87..b097a46716 100644 --- a/test/runtime/samples/store-resubscribe-b/_config.js +++ b/test/runtime/samples/store-resubscribe-b/_config.js @@ -1,3 +1,3 @@ export default { - html: `42`, + html: '42' }; diff --git a/test/runtime/samples/store-resubscribe-c/_config.js b/test/runtime/samples/store-resubscribe-c/_config.js new file mode 100644 index 0000000000..756e39bcb0 --- /dev/null +++ b/test/runtime/samples/store-resubscribe-c/_config.js @@ -0,0 +1,3 @@ +export default { + html: '31 42' +}; diff --git a/test/runtime/samples/store-resubscribe-c/main.svelte b/test/runtime/samples/store-resubscribe-c/main.svelte new file mode 100644 index 0000000000..c52a5402bd --- /dev/null +++ b/test/runtime/samples/store-resubscribe-c/main.svelte @@ -0,0 +1,16 @@ + + +{$store1} +{$store2} diff --git a/test/runtime/samples/store-resubscribe-export/_config.js b/test/runtime/samples/store-resubscribe-export/_config.js index b6e6f11344..f6630aa045 100644 --- a/test/runtime/samples/store-resubscribe-export/_config.js +++ b/test/runtime/samples/store-resubscribe-export/_config.js @@ -1,19 +1,19 @@ -let subscribeCalled = false; +let unsubscribeCalled = false; const fakeStore = val => ({ subscribe: cb => { cb(val); return { unsubscribe: () => { - subscribeCalled = true; - }, + unsubscribeCalled = true; + } }; - }, + } }); export default { props: { - foo: fakeStore(1), + foo: fakeStore(1) }, html: `

1

@@ -22,6 +22,8 @@ export default { async test({ assert, component, target }) { component.foo = fakeStore(5); - return assert.htmlEqual(target.innerHTML, `

5

`); - }, + assert.htmlEqual(target.innerHTML, '

5

'); + + assert.ok(unsubscribeCalled); + } }; diff --git a/test/runtime/samples/store-resubscribe-observable/_config.js b/test/runtime/samples/store-resubscribe-observable/_config.js index d043bbcd87..b097a46716 100644 --- a/test/runtime/samples/store-resubscribe-observable/_config.js +++ b/test/runtime/samples/store-resubscribe-observable/_config.js @@ -1,3 +1,3 @@ export default { - html: `42`, + html: '42' }; diff --git a/test/runtime/samples/store-resubscribe/_config.js b/test/runtime/samples/store-resubscribe/_config.js index 6bde764a55..82d40f9add 100644 --- a/test/runtime/samples/store-resubscribe/_config.js +++ b/test/runtime/samples/store-resubscribe/_config.js @@ -33,4 +33,4 @@ export default { `); } -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/store-shadow-scope/_config.js b/test/runtime/samples/store-shadow-scope/_config.js new file mode 100644 index 0000000000..a197325a2d --- /dev/null +++ b/test/runtime/samples/store-shadow-scope/_config.js @@ -0,0 +1,3 @@ +export default { + error: 'Stores must be declared at the top level of the component (this may change in a future version of Svelte)' +}; diff --git a/test/runtime/samples/store-shadow-scope/main.svelte b/test/runtime/samples/store-shadow-scope/main.svelte new file mode 100644 index 0000000000..72c4a06c2a --- /dev/null +++ b/test/runtime/samples/store-shadow-scope/main.svelte @@ -0,0 +1,9 @@ + diff --git a/test/runtime/samples/store-template-expression-scope/_config.js b/test/runtime/samples/store-template-expression-scope/_config.js new file mode 100644 index 0000000000..a197325a2d --- /dev/null +++ b/test/runtime/samples/store-template-expression-scope/_config.js @@ -0,0 +1,3 @@ +export default { + error: 'Stores must be declared at the top level of the component (this may change in a future version of Svelte)' +}; diff --git a/test/runtime/samples/store-template-expression-scope/main.svelte b/test/runtime/samples/store-template-expression-scope/main.svelte new file mode 100644 index 0000000000..1c9ccb2933 --- /dev/null +++ b/test/runtime/samples/store-template-expression-scope/main.svelte @@ -0,0 +1,9 @@ + + + + diff --git a/test/validator/samples/a11y-label-has-associated-control/warnings.json b/test/validator/samples/a11y-label-has-associated-control/warnings.json new file mode 100644 index 0000000000..b70a1a47de --- /dev/null +++ b/test/validator/samples/a11y-label-has-associated-control/warnings.json @@ -0,0 +1,32 @@ +[ + { + "code": "a11y-label-has-associated-control", + "end": { + "character": 16, + "column": 16, + "line": 1 + }, + "message": "A11y: A form label must be associated with a control.", + "pos": 0, + "start": { + "character": 0, + "column": 0, + "line": 1 + } + }, + { + "code": "a11y-label-has-associated-control", + "end": { + "character": 149, + "column": 30, + "line": 6 + }, + "message": "A11y: A form label must be associated with a control.", + "pos": 119, + "start": { + "character": 119, + "column": 0, + "line": 6 + } + } +] diff --git a/test/validator/samples/a11y-media-has-caption/input.svelte b/test/validator/samples/a11y-media-has-caption/input.svelte new file mode 100644 index 0000000000..105269cddb --- /dev/null +++ b/test/validator/samples/a11y-media-has-caption/input.svelte @@ -0,0 +1,4 @@ + + + + diff --git a/test/validator/samples/a11y-media-has-caption/warnings.json b/test/validator/samples/a11y-media-has-caption/warnings.json new file mode 100644 index 0000000000..a8c894b1d4 --- /dev/null +++ b/test/validator/samples/a11y-media-has-caption/warnings.json @@ -0,0 +1,32 @@ +[ + { + "code": "a11y-media-has-caption", + "end": { + "character": 55, + "column": 15, + "line": 2 + }, + "message": "A11y: Media elements must have a ", + "pos": 40, + "start": { + "character": 40, + "column": 0, + "line": 2 + } + }, + { + "code": "a11y-media-has-caption", + "end": { + "character": 80, + "column": 24, + "line": 3 + }, + "message": "A11y: Media elements must have a ", + "pos": 56, + "start": { + "character": 56, + "column": 0, + "line": 3 + } + } +] diff --git a/test/validator/samples/a11y-no-onchange/input.svelte b/test/validator/samples/a11y-no-onchange/input.svelte new file mode 100644 index 0000000000..af2041f406 --- /dev/null +++ b/test/validator/samples/a11y-no-onchange/input.svelte @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/test/validator/samples/a11y-no-onchange/warnings.json b/test/validator/samples/a11y-no-onchange/warnings.json new file mode 100644 index 0000000000..461f546c0b --- /dev/null +++ b/test/validator/samples/a11y-no-onchange/warnings.json @@ -0,0 +1,32 @@ +[ + { + "code": "a11y-no-onchange", + "end": { + "character": 88, + "column": 9, + "line": 4 + }, + "message": "A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.", + "pos": 0, + "start": { + "character": 0, + "column": 0, + "line": 1 + } + }, + { + "code": "a11y-no-onchange", + "end": { + "character": 249, + "column": 44, + "line": 10 + }, + "message": "A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.", + "pos": 209, + "start": { + "character": 209, + "column": 4, + "line": 10 + } + } +] diff --git a/test/validator/samples/action-object/input.svelte b/test/validator/samples/action-object/input.svelte new file mode 100644 index 0000000000..e0962fa594 --- /dev/null +++ b/test/validator/samples/action-object/input.svelte @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/test/validator/samples/action-object/warnings.json b/test/validator/samples/action-object/warnings.json new file mode 100644 index 0000000000..e1ccbb55a2 --- /dev/null +++ b/test/validator/samples/action-object/warnings.json @@ -0,0 +1,17 @@ +[ + { + "code": "missing-declaration", + "end": { + "character": 217, + "column": 39, + "line": 11 + }, + "message": "'foo' is not defined", + "pos": 186, + "start": { + "character": 186, + "column": 8, + "line": 11 + } + } +] diff --git a/test/validator/samples/animation-not-in-each/errors.json b/test/validator/samples/animation-not-in-each/errors.json index 67e2ceb7c2..c737617f98 100644 --- a/test/validator/samples/animation-not-in-each/errors.json +++ b/test/validator/samples/animation-not-in-each/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-animation", - "message": "An element that use the animate directive must be the immediate child of a keyed each block", + "message": "An element that uses the animate directive must be the immediate child of a keyed each block", "start": { "line": 5, "column": 5, @@ -12,4 +12,4 @@ "character": 55 }, "pos": 44 -}] \ No newline at end of file +}] diff --git a/test/validator/samples/animation-not-in-keyed-each/errors.json b/test/validator/samples/animation-not-in-keyed-each/errors.json index 1081589e6f..3e0b2d3c0c 100644 --- a/test/validator/samples/animation-not-in-keyed-each/errors.json +++ b/test/validator/samples/animation-not-in-keyed-each/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-animation", - "message": "An element that use the animate directive must be the immediate child of a keyed each block", + "message": "An element that uses the animate directive must be the immediate child of a keyed each block", "start": { "line": 6, "column": 6, @@ -12,4 +12,4 @@ "character": 80 }, "pos": 69 -}] \ No newline at end of file +}] diff --git a/test/validator/samples/animation-siblings/errors.json b/test/validator/samples/animation-siblings/errors.json index af15113b94..3def56f0a5 100644 --- a/test/validator/samples/animation-siblings/errors.json +++ b/test/validator/samples/animation-siblings/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-animation", - "message": "An element that use the animate directive must be the sole child of a keyed each block", + "message": "An element that uses the animate directive must be the sole child of a keyed each block", "start": { "line": 6, "column": 6, @@ -12,4 +12,4 @@ "character": 88 }, "pos": 77 -}] \ No newline at end of file +}] diff --git a/test/validator/samples/attribute-invalid-name-2/errors.json b/test/validator/samples/attribute-invalid-name-2/errors.json new file mode 100644 index 0000000000..9e0c437339 --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-2/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "illegal-attribute", + "message": "'3aa' is not a valid attribute name", + "start": { + "line": 1, + "column": 3, + "character": 3 + }, + "end": { + "line": 1, + "column": 12, + "character": 12 + }, + "pos": 3 +}] diff --git a/test/validator/samples/attribute-invalid-name-2/input.svelte b/test/validator/samples/attribute-invalid-name-2/input.svelte new file mode 100644 index 0000000000..6958a1b5aa --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-2/input.svelte @@ -0,0 +1 @@ +

Test

diff --git a/test/validator/samples/attribute-invalid-name-3/errors.json b/test/validator/samples/attribute-invalid-name-3/errors.json new file mode 100644 index 0000000000..f583226882 --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-3/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "illegal-attribute", + "message": "'a*a' is not a valid attribute name", + "start": { + "line": 1, + "column": 3, + "character": 3 + }, + "end": { + "line": 1, + "column": 6, + "character": 6 + }, + "pos": 3 +}] diff --git a/test/validator/samples/attribute-invalid-name-3/input.svelte b/test/validator/samples/attribute-invalid-name-3/input.svelte new file mode 100644 index 0000000000..87c2df979a --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-3/input.svelte @@ -0,0 +1 @@ +

Test

diff --git a/test/validator/samples/attribute-invalid-name-4/errors.json b/test/validator/samples/attribute-invalid-name-4/errors.json new file mode 100644 index 0000000000..a8959cebf3 --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-4/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "illegal-attribute", + "message": "'-a' is not a valid attribute name", + "start": { + "line": 1, + "column": 3, + "character": 3 + }, + "end": { + "line": 1, + "column": 5, + "character": 5 + }, + "pos": 3 +}] diff --git a/test/validator/samples/attribute-invalid-name-4/input.svelte b/test/validator/samples/attribute-invalid-name-4/input.svelte new file mode 100644 index 0000000000..92f68449b9 --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-4/input.svelte @@ -0,0 +1 @@ +

Test

diff --git a/test/validator/samples/attribute-invalid-name-5/errors.json b/test/validator/samples/attribute-invalid-name-5/errors.json new file mode 100644 index 0000000000..b1e3acc5ef --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-5/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "illegal-attribute", + "message": "'a;' is not a valid attribute name", + "start": { + "line": 1, + "column": 3, + "character": 3 + }, + "end": { + "line": 1, + "column": 11, + "character": 11 + }, + "pos": 3 +}] diff --git a/test/validator/samples/attribute-invalid-name-5/input.svelte b/test/validator/samples/attribute-invalid-name-5/input.svelte new file mode 100644 index 0000000000..3a7dd05137 --- /dev/null +++ b/test/validator/samples/attribute-invalid-name-5/input.svelte @@ -0,0 +1 @@ +

Test

diff --git a/test/validator/samples/attribute-invalid-name/errors.json b/test/validator/samples/attribute-invalid-name/errors.json new file mode 100644 index 0000000000..9bdde1ee46 --- /dev/null +++ b/test/validator/samples/attribute-invalid-name/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "illegal-attribute", + "message": "'}' is not a valid attribute name", + "start": { + "line": 1, + "column": 3, + "character": 3 + }, + "end": { + "line": 1, + "column": 4, + "character": 4 + }, + "pos": 3 +}] diff --git a/test/validator/samples/attribute-invalid-name/input.svelte b/test/validator/samples/attribute-invalid-name/input.svelte new file mode 100644 index 0000000000..56d9cfe23f --- /dev/null +++ b/test/validator/samples/attribute-invalid-name/input.svelte @@ -0,0 +1 @@ +

Test

diff --git a/test/validator/samples/await-shorthand-no-then/input.svelte b/test/validator/samples/await-shorthand-no-then/input.svelte new file mode 100644 index 0000000000..6e8a99f131 --- /dev/null +++ b/test/validator/samples/await-shorthand-no-then/input.svelte @@ -0,0 +1,7 @@ + + +{#await promise catch error} +

Error: {error}

+{/await} diff --git a/test/validator/samples/await-shorthand-no-then/warnings.json b/test/validator/samples/await-shorthand-no-then/warnings.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/await-shorthand-no-then/warnings.json @@ -0,0 +1 @@ +[] diff --git a/test/validator/samples/binding-const-field/errors.json b/test/validator/samples/binding-const-field/errors.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/binding-const-field/errors.json @@ -0,0 +1 @@ +[] diff --git a/test/validator/samples/binding-const-field/input.svelte b/test/validator/samples/binding-const-field/input.svelte new file mode 100644 index 0000000000..055a16438d --- /dev/null +++ b/test/validator/samples/binding-const-field/input.svelte @@ -0,0 +1,7 @@ + + + diff --git a/test/validator/samples/binding-const/errors.json b/test/validator/samples/binding-const/errors.json new file mode 100644 index 0000000000..6d48af9c4e --- /dev/null +++ b/test/validator/samples/binding-const/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "invalid-binding", + "message": "Cannot bind to a variable which is not writable", + "pos": 61, + "start": { + "line": 5, + "column": 19, + "character": 61 + }, + "end": { + "line": 5, + "column": 24, + "character": 66 + } +}] \ No newline at end of file diff --git a/test/validator/samples/binding-const/input.svelte b/test/validator/samples/binding-const/input.svelte new file mode 100644 index 0000000000..1857a1932c --- /dev/null +++ b/test/validator/samples/binding-const/input.svelte @@ -0,0 +1,5 @@ + + + diff --git a/test/validator/samples/component-name-lowercase/input.svelte b/test/validator/samples/component-name-lowercase/input.svelte new file mode 100644 index 0000000000..ebd7cf3481 --- /dev/null +++ b/test/validator/samples/component-name-lowercase/input.svelte @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/test/validator/samples/component-name-lowercase/warnings.json b/test/validator/samples/component-name-lowercase/warnings.json new file mode 100644 index 0000000000..37765b423d --- /dev/null +++ b/test/validator/samples/component-name-lowercase/warnings.json @@ -0,0 +1,17 @@ +[ + { + "code": "component-name-lowercase", + "message": " will be treated as an HTML element unless it begins with a capital letter", + "pos": 82, + "start": { + "character": 82, + "column": 0, + "line": 6 + }, + "end": { + "character": 102, + "column": 20, + "line": 6 + } + } +] diff --git a/test/validator/samples/component-slotted-custom-element-2/errors.json b/test/validator/samples/component-slotted-custom-element-2/errors.json new file mode 100644 index 0000000000..06be51d72d --- /dev/null +++ b/test/validator/samples/component-slotted-custom-element-2/errors.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-slotted-content", + "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", + "start": { "line": 10, "column": 9, "character": 138 }, + "end": { "line": 10, "column": 19, "character": 148 }, + "pos": 138 + } +] diff --git a/test/validator/samples/component-slotted-custom-element-2/input.svelte b/test/validator/samples/component-slotted-custom-element-2/input.svelte new file mode 100644 index 0000000000..221659ca4d --- /dev/null +++ b/test/validator/samples/component-slotted-custom-element-2/input.svelte @@ -0,0 +1,14 @@ + + + + + {#if thing} +
+
+
+ {/if} + + \ No newline at end of file diff --git a/test/validator/samples/component-slotted-custom-element/errors.json b/test/validator/samples/component-slotted-custom-element/errors.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/test/validator/samples/component-slotted-custom-element/errors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/validator/samples/component-slotted-custom-element/input.svelte b/test/validator/samples/component-slotted-custom-element/input.svelte new file mode 100644 index 0000000000..e0e27834c1 --- /dev/null +++ b/test/validator/samples/component-slotted-custom-element/input.svelte @@ -0,0 +1,15 @@ + + + + +
+
+
+ {#if thing} +
+ {/if} + + \ No newline at end of file diff --git a/test/validator/samples/component-slotted-each-block/errors.json b/test/validator/samples/component-slotted-each-block/errors.json index 89f394bca4..2944acae17 100644 --- a/test/validator/samples/component-slotted-each-block/errors.json +++ b/test/validator/samples/component-slotted-each-block/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-slotted-content", - "message": "Cannot place slotted elements inside an each-block", + "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "start": { "line": 7, "column": 7, diff --git a/test/validator/samples/component-slotted-if-block/errors.json b/test/validator/samples/component-slotted-if-block/errors.json index ab35a77fce..3ae07c1b3b 100644 --- a/test/validator/samples/component-slotted-if-block/errors.json +++ b/test/validator/samples/component-slotted-if-block/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-slotted-content", - "message": "Cannot place slotted elements inside an if-block", + "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "start": { "line": 7, "column": 7, diff --git a/test/validator/samples/each-block-destructured-object-rest-comma-after/errors.json b/test/validator/samples/each-block-destructured-object-rest-comma-after/errors.json index 549b6960eb..df899b7702 100644 --- a/test/validator/samples/each-block-destructured-object-rest-comma-after/errors.json +++ b/test/validator/samples/each-block-destructured-object-rest-comma-after/errors.json @@ -1,5 +1,5 @@ [{ - "code": "comma-after-rest", + "code": "parse-error", "message": "Comma is not permitted after the rest element", "pos": 100, "start": { diff --git a/test/validator/samples/each-block-invalid-context-destructured-object/errors.json b/test/validator/samples/each-block-invalid-context-destructured-object/errors.json index 085021ff5a..c96e3d2c8c 100644 --- a/test/validator/samples/each-block-invalid-context-destructured-object/errors.json +++ b/test/validator/samples/each-block-invalid-context-destructured-object/errors.json @@ -1,6 +1,6 @@ [{ - "code": "unexpected-reserved-word", - "message": "'case' is a reserved word in JavaScript and cannot be used here", + "code": "parse-error", + "message": "Unexpected keyword 'case'", "start": { "line": 1, "column": 18, diff --git a/test/validator/samples/each-block-invalid-context-destructured/errors.json b/test/validator/samples/each-block-invalid-context-destructured/errors.json index afe99ee219..62d6f62e87 100644 --- a/test/validator/samples/each-block-invalid-context-destructured/errors.json +++ b/test/validator/samples/each-block-invalid-context-destructured/errors.json @@ -1,6 +1,6 @@ [{ - "code": "unexpected-reserved-word", - "message": "'case' is a reserved word in JavaScript and cannot be used here", + "code": "parse-error", + "message": "Unexpected token", "start": { "line": 1, "column": 17, diff --git a/test/validator/samples/each-block-multiple-children/_config.js b/test/validator/samples/each-block-multiple-children/_config.js index e26996239d..083edcd210 100644 --- a/test/validator/samples/each-block-multiple-children/_config.js +++ b/test/validator/samples/each-block-multiple-children/_config.js @@ -1,3 +1,3 @@ export default { dev: true -}; \ No newline at end of file +}; diff --git a/test/validator/samples/event-modifiers-invalid-nonpassive/errors.json b/test/validator/samples/event-modifiers-invalid-nonpassive/errors.json new file mode 100644 index 0000000000..a7e5a2a76c --- /dev/null +++ b/test/validator/samples/event-modifiers-invalid-nonpassive/errors.json @@ -0,0 +1,15 @@ +[{ + "message": "The 'passive' and 'nonpassive' modifiers cannot be used together", + "code": "invalid-event-modifier", + "start": { + "line": 1, + "column": 5, + "character": 5 + }, + "end": { + "line": 1, + "column": 51, + "character": 51 + }, + "pos": 5 +}] diff --git a/test/validator/samples/event-modifiers-invalid-nonpassive/input.svelte b/test/validator/samples/event-modifiers-invalid-nonpassive/input.svelte new file mode 100644 index 0000000000..3557aa4b1d --- /dev/null +++ b/test/validator/samples/event-modifiers-invalid-nonpassive/input.svelte @@ -0,0 +1,3 @@ +
+ oops +
\ No newline at end of file diff --git a/test/validator/samples/event-modifiers-invalid/errors.json b/test/validator/samples/event-modifiers-invalid/errors.json index 8be2ca7348..59a142d632 100644 --- a/test/validator/samples/event-modifiers-invalid/errors.json +++ b/test/validator/samples/event-modifiers-invalid/errors.json @@ -1,5 +1,5 @@ [{ - "message": "Valid event modifiers are preventDefault, stopPropagation, capture, once, passive or self", + "message": "Valid event modifiers are preventDefault, stopPropagation, capture, once, passive, nonpassive or self", "code": "invalid-event-modifier", "start": { "line": 1, diff --git a/test/validator/samples/event-modifiers-legacy/_config.js b/test/validator/samples/event-modifiers-legacy/_config.js index 0179e05ec4..52f59c8767 100644 --- a/test/validator/samples/event-modifiers-legacy/_config.js +++ b/test/validator/samples/event-modifiers-legacy/_config.js @@ -1,3 +1,3 @@ export default { legacy: true -}; \ No newline at end of file +}; diff --git a/test/validator/samples/import-meta/errors.json b/test/validator/samples/import-meta/errors.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/test/validator/samples/import-meta/errors.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/validator/samples/import-meta/input.svelte b/test/validator/samples/import-meta/input.svelte new file mode 100644 index 0000000000..a5ce32dd77 --- /dev/null +++ b/test/validator/samples/import-meta/input.svelte @@ -0,0 +1,6 @@ + + +{url} +{import.meta.url} diff --git a/test/validator/samples/non-empty-block-dev/_config.js b/test/validator/samples/non-empty-block-dev/_config.js index e26996239d..083edcd210 100644 --- a/test/validator/samples/non-empty-block-dev/_config.js +++ b/test/validator/samples/non-empty-block-dev/_config.js @@ -1,3 +1,3 @@ export default { dev: true -}; \ No newline at end of file +}; diff --git a/test/validator/samples/slot-attribute-invalid/errors.json b/test/validator/samples/slot-attribute-invalid/errors.json index fc01fa9792..a75fdc065c 100644 --- a/test/validator/samples/slot-attribute-invalid/errors.json +++ b/test/validator/samples/slot-attribute-invalid/errors.json @@ -1,6 +1,6 @@ [{ "code": "invalid-slotted-content", - "message": "Element with a slot='...' attribute must be a descendant of a component or custom element", + "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "start": { "line": 1, "column": 5, diff --git a/test/vars/index.js b/test/vars/index.ts similarity index 95% rename from test/vars/index.js rename to test/vars/index.ts index a12ac177f2..4cebf7fbb4 100644 --- a/test/vars/index.js +++ b/test/vars/index.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as assert from 'assert'; -import { svelte, loadConfig, tryToLoadJson } from '../helpers.js'; +import { svelte, loadConfig, tryToLoadJson } from '../helpers'; describe('vars', () => { fs.readdirSync(`${__dirname}/samples`).forEach(dir => { diff --git a/test/vars/samples/$$props-logicless/_config.js b/test/vars/samples/$$props-logicless/_config.js index 20f9b99466..05bbe7e0b2 100644 --- a/test/vars/samples/$$props-logicless/_config.js +++ b/test/vars/samples/$$props-logicless/_config.js @@ -14,4 +14,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/$$props/_config.js b/test/vars/samples/$$props/_config.js index 20f9b99466..05bbe7e0b2 100644 --- a/test/vars/samples/$$props/_config.js +++ b/test/vars/samples/$$props/_config.js @@ -14,4 +14,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/assumed-global/_config.js b/test/vars/samples/assumed-global/_config.js index 2b84e83f12..782760bb8b 100644 --- a/test/vars/samples/assumed-global/_config.js +++ b/test/vars/samples/assumed-global/_config.js @@ -1,5 +1,5 @@ export default { test(assert, vars) { assert.deepEqual(vars, []); - }, + } }; diff --git a/test/vars/samples/component-namespaced/_config.js b/test/vars/samples/component-namespaced/_config.js index a801c52780..8ed4872355 100644 --- a/test/vars/samples/component-namespaced/_config.js +++ b/test/vars/samples/component-namespaced/_config.js @@ -14,4 +14,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/duplicate-globals/_config.js b/test/vars/samples/duplicate-globals/_config.js index 2b84e83f12..782760bb8b 100644 --- a/test/vars/samples/duplicate-globals/_config.js +++ b/test/vars/samples/duplicate-globals/_config.js @@ -1,5 +1,5 @@ export default { test(assert, vars) { assert.deepEqual(vars, []); - }, + } }; diff --git a/test/vars/samples/duplicate-non-hoistable/_config.js b/test/vars/samples/duplicate-non-hoistable/_config.js index 4ebc5b00cf..bd70e29800 100644 --- a/test/vars/samples/duplicate-non-hoistable/_config.js +++ b/test/vars/samples/duplicate-non-hoistable/_config.js @@ -13,5 +13,5 @@ export default { writable: true } ]); - }, + } }; diff --git a/test/vars/samples/duplicate-vars/_config.js b/test/vars/samples/duplicate-vars/_config.js index eb10c44a9a..749a0c59af 100644 --- a/test/vars/samples/duplicate-vars/_config.js +++ b/test/vars/samples/duplicate-vars/_config.js @@ -24,5 +24,5 @@ export default { writable: true } ]); - }, + } }; diff --git a/test/vars/samples/implicit-reactive/_config.js b/test/vars/samples/implicit-reactive/_config.js index 770de590e6..a8bf261d4f 100644 --- a/test/vars/samples/implicit-reactive/_config.js +++ b/test/vars/samples/implicit-reactive/_config.js @@ -24,5 +24,5 @@ export default { writable: true } ]); - }, + } }; diff --git a/test/vars/samples/imports/_config.js b/test/vars/samples/imports/_config.js index ecf120c7d6..47e8c0c5d9 100644 --- a/test/vars/samples/imports/_config.js +++ b/test/vars/samples/imports/_config.js @@ -36,4 +36,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/modules-vars/_config.js b/test/vars/samples/modules-vars/_config.js index e178941db6..52b8940148 100644 --- a/test/vars/samples/modules-vars/_config.js +++ b/test/vars/samples/modules-vars/_config.js @@ -2,7 +2,7 @@ export default { test(assert, vars) { assert.deepEqual(vars, [ { - name: "a", + name: 'a', export_name: null, injected: false, module: true, @@ -13,7 +13,7 @@ export default { writable: true }, { - name: "b", + name: 'b', export_name: null, injected: false, module: true, @@ -24,7 +24,7 @@ export default { writable: true }, { - name: "c", + name: 'c', export_name: null, injected: false, module: true, @@ -35,7 +35,7 @@ export default { writable: true }, { - name: "d", + name: 'd', export_name: null, injected: false, module: true, @@ -46,7 +46,7 @@ export default { writable: true }, { - name: "c", + name: 'c', export_name: null, injected: false, module: false, @@ -57,7 +57,7 @@ export default { writable: true }, { - name: "foo", + name: 'foo', export_name: null, injected: false, module: false, diff --git a/test/vars/samples/mutated-vs-reassigned-bindings/_config.js b/test/vars/samples/mutated-vs-reassigned-bindings/_config.js index ba499674d2..65c7d5cc90 100644 --- a/test/vars/samples/mutated-vs-reassigned-bindings/_config.js +++ b/test/vars/samples/mutated-vs-reassigned-bindings/_config.js @@ -25,4 +25,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/mutated-vs-reassigned/_config.js b/test/vars/samples/mutated-vs-reassigned/_config.js index ba499674d2..65c7d5cc90 100644 --- a/test/vars/samples/mutated-vs-reassigned/_config.js +++ b/test/vars/samples/mutated-vs-reassigned/_config.js @@ -25,4 +25,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/props/_config.js b/test/vars/samples/props/_config.js index a51c93fb03..d5f5d1cc2b 100644 --- a/test/vars/samples/props/_config.js +++ b/test/vars/samples/props/_config.js @@ -47,4 +47,4 @@ export default { } ]); } -}; \ No newline at end of file +}; diff --git a/test/vars/samples/referenced-from-script/_config.js b/test/vars/samples/referenced-from-script/_config.js index 191a52f8cc..ec068cb1d7 100644 --- a/test/vars/samples/referenced-from-script/_config.js +++ b/test/vars/samples/referenced-from-script/_config.js @@ -10,7 +10,7 @@ export default { reassigned: false, referenced: false, writable: false, - referenced_from_script: false, + referenced_from_script: false }, { name: 'j', @@ -21,7 +21,7 @@ export default { reassigned: false, referenced: false, writable: false, - referenced_from_script: false, + referenced_from_script: false }, { name: 'k', @@ -32,7 +32,7 @@ export default { reassigned: false, referenced: false, writable: false, - referenced_from_script: false, + referenced_from_script: false }, { name: 'a', @@ -43,7 +43,7 @@ export default { reassigned: true, referenced: false, writable: true, - referenced_from_script: true, + referenced_from_script: true }, { name: 'b', @@ -54,7 +54,7 @@ export default { reassigned: false, referenced: false, writable: true, - referenced_from_script: true, + referenced_from_script: true }, { name: 'c', @@ -65,7 +65,7 @@ export default { reassigned: false, referenced: false, writable: true, - referenced_from_script: true, + referenced_from_script: true }, { name: 'd', @@ -76,7 +76,7 @@ export default { reassigned: false, referenced: false, writable: true, - referenced_from_script: true, + referenced_from_script: true }, { name: 'e', @@ -87,7 +87,7 @@ export default { reassigned: false, referenced: false, writable: true, - referenced_from_script: false, + referenced_from_script: false }, { name: 'f', @@ -98,7 +98,7 @@ export default { reassigned: false, referenced: false, writable: true, - referenced_from_script: false, + referenced_from_script: false }, { name: 'g', @@ -109,7 +109,7 @@ export default { reassigned: false, referenced: false, writable: true, - referenced_from_script: true, + referenced_from_script: true }, { name: 'h', @@ -120,7 +120,7 @@ export default { reassigned: true, referenced: false, writable: true, - referenced_from_script: true, + referenced_from_script: true }, { name: 'foo', @@ -131,7 +131,7 @@ export default { reassigned: false, referenced: false, writable: false, - referenced_from_script: false, + referenced_from_script: false }, { name: 'l', @@ -142,7 +142,7 @@ export default { reassigned: false, referenced: false, referenced_from_script: true, - writable: false, + writable: false }, { name: 'bar', @@ -153,8 +153,8 @@ export default { reassigned: false, referenced: false, writable: false, - referenced_from_script: false, - }, + referenced_from_script: false + } ]); - }, + } }; diff --git a/test/vars/samples/template-references/_config.js b/test/vars/samples/template-references/_config.js index 674e351517..34c07e19e0 100644 --- a/test/vars/samples/template-references/_config.js +++ b/test/vars/samples/template-references/_config.js @@ -10,7 +10,7 @@ export default { reassigned: false, referenced: true, referenced_from_script: false, - writable: false, + writable: false }, { export_name: null, @@ -21,7 +21,7 @@ export default { reassigned: false, referenced: true, referenced_from_script: false, - writable: true, + writable: true }, { export_name: null, @@ -32,8 +32,8 @@ export default { reassigned: false, referenced: true, referenced_from_script: false, - writable: true, - }, + writable: true + } ]); - }, + } }; diff --git a/test/vars/samples/undeclared/_config.js b/test/vars/samples/undeclared/_config.js index 2b84e83f12..782760bb8b 100644 --- a/test/vars/samples/undeclared/_config.js +++ b/test/vars/samples/undeclared/_config.js @@ -1,5 +1,5 @@ export default { test(assert, vars) { assert.deepEqual(vars, []); - }, + } };