some text
`, 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 212c57308a..a07a1482bc 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 +}; \ No newline at end of file diff --git a/test/runtime/samples/element-invalid-name/_config.js b/test/runtime/samples/element-invalid-name/_config.js index af6e4933ce..d70c920a19 100644 --- a/test/runtime/samples/element-invalid-name/_config.js +++ b/test/runtime/samples/element-invalid-name/_config.js @@ -2,4 +2,4 @@ export default { html: `internal: 1
- - `, + html: ` +internal: 1
+ + `, - async test({ assert, target, window }) { - const button = target.querySelector('button'); - const click = new window.MouseEvent('click'); + async test({ assert, target, window }) { + const button = target.querySelector('button'); + const click = new window.MouseEvent('click'); - await button.dispatchEvent(click); + await button.dispatchEvent(click); - assert.htmlEqual(target.innerHTML, ` -internal: 1
- - `); - } -}; \ No newline at end of file + assert.htmlEqual(target.innerHTML, ` +internal: 1
+ + `); + } +}; diff --git a/test/runtime/samples/mixed-let-export/_config.js b/test/runtime/samples/mixed-let-export/_config.js index 5ac8585742..f3da4215d9 100644 --- a/test/runtime/samples/mixed-let-export/_config.js +++ b/test/runtime/samples/mixed-let-export/_config.js @@ -1,9 +1,9 @@ export default { - props: { - a: 42 - }, + props: { + a: 42 + }, - html: ` - 42 - ` -} + html: ` + 42 + ` +}; diff --git a/test/runtime/samples/prop-exports/_config.js b/test/runtime/samples/prop-exports/_config.js index 631c9eb0ad..e1620c015f 100644 --- a/test/runtime/samples/prop-exports/_config.js +++ b/test/runtime/samples/prop-exports/_config.js @@ -2,29 +2,29 @@ import { writable } from '../../../../store'; export default { props: { - s1: writable(42), - s2: writable(43), - p1: 2, - p3: 3, - a1: writable(1), - a2: 4, - a6: writable(29), - for: 'loop', - continue: '...', + s1: writable(42), + s2: writable(43), + p1: 2, + p3: 3, + a1: writable(1), + a2: 4, + a6: writable(29), + for: 'loop', + continue: '...', }, html: ` - $s1=42 - $s2=43 - p1=2 - p3=3 - $v1=1 - v2=4 - vi1=4 - $vs1=1 - vl0=hello - vl1=test - $s3=29 - loop... - ` -} + $s1=42 + $s2=43 + p1=2 + p3=3 + $v1=1 + v2=4 + vi1=4 + $vs1=1 + vl0=hello + vl1=test + $s3=29 + loop... + ` +}; diff --git a/test/runtime/samples/spring/_config.js b/test/runtime/samples/spring/_config.js index 79399b777a..49367ce08b 100644 --- a/test/runtime/samples/spring/_config.js +++ b/test/runtime/samples/spring/_config.js @@ -1,3 +1,3 @@ export default { html: `0
` -} \ No newline at end of file +}; diff --git a/test/runtime/samples/transition-js-await-block/_config.js b/test/runtime/samples/transition-js-await-block/_config.js index 2e01dd7f76..80546ae6b8 100644 --- a/test/runtime/samples/transition-js-await-block/_config.js +++ b/test/runtime/samples/transition-js-await-block/_config.js @@ -1,7 +1,7 @@ let fulfil; let reject; -let promise = new Promise((f, r) => { +const promise = new Promise((f, r) => { fulfil = f; reject = r; }); @@ -14,7 +14,7 @@ export default { intro: true, test({ assert, target, raf }) { - let p = target.querySelector('p'); + const p = target.querySelector('p'); assert.equal(p.className, 'pending'); assert.equal(p.foo, 0); @@ -26,7 +26,7 @@ export default { return promise.then(() => { raf.tick(80); - let ps = document.querySelectorAll('p'); + const ps = document.querySelectorAll('p'); assert.equal(ps[1].className, 'pending'); assert.equal(ps[0].className, 'then'); assert.equal(ps[1].foo, 0.2); diff --git a/test/server-side-rendering/index.js b/test/server-side-rendering/index.js index 4b648c0591..cf6e5ad964 100644 --- a/test/server-side-rendering/index.js +++ b/test/server-side-rendering/index.js @@ -1,7 +1,6 @@ import * as assert from "assert"; import * as fs from "fs"; import * as path from "path"; -import * as glob from 'tiny-glob/sync.js'; import { showOutput, diff --git a/test/server-side-rendering/samples/text-area-bind/_expected.html b/test/server-side-rendering/samples/text-area-bind/_expected.html new file mode 100644 index 0000000000..c3c8441f56 --- /dev/null +++ b/test/server-side-rendering/samples/text-area-bind/_expected.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/server-side-rendering/samples/text-area-bind/main.svelte b/test/server-side-rendering/samples/text-area-bind/main.svelte new file mode 100644 index 0000000000..7126e09375 --- /dev/null +++ b/test/server-side-rendering/samples/text-area-bind/main.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/test/setup.js b/test/setup.js index 8bb73d81d0..7406a07dd9 100644 --- a/test/setup.js +++ b/test/setup.js @@ -7,7 +7,7 @@ process.env.TEST = true; require.extensions['.js'] = function(module, filename) { const exports = []; - var code = fs.readFileSync(filename, 'utf-8') + let code = fs.readFileSync(filename, 'utf-8') .replace(/^import \* as (\w+) from ['"]([^'"]+)['"];?/gm, 'var $1 = require("$2");') .replace(/^import (\w+) from ['"]([^'"]+)['"];?/gm, 'var {default: $1} = require("$2");') .replace(/^import {([^}]+)} from ['"](.+)['"];?/gm, 'var {$1} = require("$2");') @@ -35,4 +35,4 @@ require.extensions['.js'] = function(module, filename) { console.log(code); // eslint-disable-line no-console throw err; } -}; \ No newline at end of file +}; diff --git a/test/sourcemaps/index.js b/test/sourcemaps/index.js index 79028719b9..ee169ebe1b 100644 --- a/test/sourcemaps/index.js +++ b/test/sourcemaps/index.js @@ -1,7 +1,7 @@ import * as fs from "fs"; import * as path from "path"; import * as assert from "assert"; -import { loadConfig, svelte } from "../helpers.js"; +import { svelte } from "../helpers.js"; import { SourceMapConsumer } from "source-map"; import { getLocator } from "locate-character"; @@ -18,8 +18,6 @@ describe("sourcemaps", () => { } (solo ? it.only : skip ? it.skip : it)(dir, () => { - const config = loadConfig(`./sourcemaps/samples/${dir}/_config.js`); - const filename = path.resolve( `test/sourcemaps/samples/${dir}/input.svelte` ); diff --git a/test/store/index.ts b/test/store/index.ts index 13b8e1f869..bb999f1220 100644 --- a/test/store/index.ts +++ b/test/store/index.ts @@ -49,7 +49,7 @@ describe('store', () => { const store = writable(obj); - store.subscribe(value => { + store.subscribe(() => { called += 1; }); @@ -189,6 +189,34 @@ describe('store', () => { unsubscribe(); }); + it('prevents diamond dependency problem', () => { + const count = writable(0); + const values = []; + + const a = derived(count, $count => { + return 'a' + $count; + }); + + const b = derived(count, $count => { + return 'b' + $count; + }); + + const combined = derived([a, b], ([a, b]) => { + return a + b; + }); + + const unsubscribe = combined.subscribe(v => { + values.push(v); + }); + + assert.deepEqual(values, ['a0b0']); + + count.set(1); + assert.deepEqual(values, ['a0b0', 'a1b1']); + + unsubscribe(); + }); + it('is updated with safe_not_equal logic', () => { const arr = [0]; diff --git a/test/test.js b/test/test.js index 380bbee304..7759941dbb 100644 --- a/test/test.js +++ b/test/test.js @@ -2,6 +2,6 @@ const glob = require("tiny-glob/sync.js"); require("./setup"); -glob("*/index.{js,ts}", { cwd: "test" }).forEach(function(file) { +glob("*/index.{js,ts}", { cwd: "test" }).forEach((file) => { require("./" + file); -}); \ No newline at end of file +}); diff --git a/test/validator/index.js b/test/validator/index.js index b26b087bb3..1e54cc20db 100644 --- a/test/validator/index.js +++ b/test/validator/index.js @@ -24,7 +24,7 @@ describe("validate", () => { let error; try { - let { warnings } = svelte.compile(input, { + const { warnings } = svelte.compile(input, { dev: config.dev, legacy: config.legacy, generate: false @@ -59,7 +59,7 @@ describe("validate", () => { assert.deepEqual(error.end, expected.end); assert.equal(error.pos, expected.pos); } catch (e) { - console.error(error) + console.error(error); // eslint-disable-line no-console throw e; } } diff --git a/tsconfig.json b/tsconfig.json index 9ac29a84fe..07bc24acaf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,8 @@ "declaration": true, "declarationDir": "types", "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, "noEmitOnError": true, "lib": [ "es5",