From 636787d55976b3d49b07ded23061f11a08869a59 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 25 Nov 2018 21:43:47 -0500 Subject: [PATCH] get most hydration tests passing --- test/custom-elements/index.js | 2 +- test/hydration/index.js | 8 ++++---- test/hydration/samples/binding-input/_config.js | 2 +- test/hydration/samples/dynamic-text-changed/_config.js | 2 +- test/hydration/samples/dynamic-text/_config.js | 2 +- test/hydration/samples/each-block-arg-clash/_config.js | 2 +- test/hydration/samples/each-block/_config.js | 2 +- test/hydration/samples/element-attribute-added/_config.js | 4 ++-- test/hydration/samples/element-attribute-added/main.html | 2 +- .../samples/element-attribute-changed/_config.js | 2 +- .../samples/element-attribute-removed/_config.js | 2 +- test/hydration/samples/element-ref/main.html | 4 ++++ test/hydration/samples/event-handler/_config.js | 2 +- test/hydration/samples/if-block-anchor/_config.js | 2 +- test/hydration/samples/if-block-false/_config.js | 2 +- test/hydration/samples/if-block-update/_config.js | 5 +++-- test/hydration/samples/if-block/_config.js | 2 +- test/hydration/samples/raw/_config.js | 2 +- 18 files changed, 27 insertions(+), 22 deletions(-) diff --git a/test/custom-elements/index.js b/test/custom-elements/index.js index 257940273f..1c4e64cf28 100644 --- a/test/custom-elements/index.js +++ b/test/custom-elements/index.js @@ -15,7 +15,7 @@ const page = ` const assert = fs.readFileSync('test/custom-elements/assert.js', 'utf-8'); -describe.only('custom-elements', function() { +describe('custom-elements', function() { this.timeout(10000); let svelte; diff --git a/test/hydration/index.js b/test/hydration/index.js index 62d2632866..42e954b695 100644 --- a/test/hydration/index.js +++ b/test/hydration/index.js @@ -17,7 +17,7 @@ function getName(filename) { return base[0].toUpperCase() + base.slice(1); } -describe('hydration', () => { +describe.only('hydration', () => { before(() => { const svelte = loadSvelte(); @@ -48,7 +48,7 @@ describe('hydration', () => { const cwd = path.resolve(`test/hydration/samples/${dir}`); compileOptions = config.compileOptions || {}; - compileOptions.shared = path.resolve('shared.js'); + compileOptions.shared = path.resolve('internal.js'); compileOptions.dev = config.dev; compileOptions.hydrate = true; @@ -60,7 +60,7 @@ describe('hydration', () => { let SvelteComponent; try { - SvelteComponent = require(`${cwd}/main.html`); + SvelteComponent = require(`${cwd}/main.html`).default; } catch (err) { throw err; } @@ -73,7 +73,7 @@ describe('hydration', () => { const component = new SvelteComponent({ target, hydrate: true, - data: config.data + props: config.props }); assert.htmlEqual(target.innerHTML, fs.readFileSync(`${cwd}/_after.html`, 'utf-8')); diff --git a/test/hydration/samples/binding-input/_config.js b/test/hydration/samples/binding-input/_config.js index 422e2a496c..9004d06490 100644 --- a/test/hydration/samples/binding-input/_config.js +++ b/test/hydration/samples/binding-input/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { name: 'world' }, diff --git a/test/hydration/samples/dynamic-text-changed/_config.js b/test/hydration/samples/dynamic-text-changed/_config.js index e836ebf4b2..467aef49ac 100644 --- a/test/hydration/samples/dynamic-text-changed/_config.js +++ b/test/hydration/samples/dynamic-text-changed/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { name: 'everybody' }, diff --git a/test/hydration/samples/dynamic-text/_config.js b/test/hydration/samples/dynamic-text/_config.js index 3ca70ee5d2..a7f0fc3d8b 100644 --- a/test/hydration/samples/dynamic-text/_config.js +++ b/test/hydration/samples/dynamic-text/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { name: 'world' }, diff --git a/test/hydration/samples/each-block-arg-clash/_config.js b/test/hydration/samples/each-block-arg-clash/_config.js index 3efdf81cec..1b04393629 100644 --- a/test/hydration/samples/each-block-arg-clash/_config.js +++ b/test/hydration/samples/each-block-arg-clash/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { things: { foo: [ 'animal', diff --git a/test/hydration/samples/each-block/_config.js b/test/hydration/samples/each-block/_config.js index 065ae25cb9..5c58a4c232 100644 --- a/test/hydration/samples/each-block/_config.js +++ b/test/hydration/samples/each-block/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { things: [ 'animal', 'vegetable', diff --git a/test/hydration/samples/element-attribute-added/_config.js b/test/hydration/samples/element-attribute-added/_config.js index a1cfe933c2..fb4a90bd3d 100644 --- a/test/hydration/samples/element-attribute-added/_config.js +++ b/test/hydration/samples/element-attribute-added/_config.js @@ -1,6 +1,6 @@ export default { - data: { - class: 'bar' + props: { + className: 'bar' }, snapshot(target) { diff --git a/test/hydration/samples/element-attribute-added/main.html b/test/hydration/samples/element-attribute-added/main.html index 335e3d4e1f..c47595732e 100644 --- a/test/hydration/samples/element-attribute-added/main.html +++ b/test/hydration/samples/element-attribute-added/main.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/hydration/samples/element-attribute-changed/_config.js b/test/hydration/samples/element-attribute-changed/_config.js index a1cfe933c2..05881f748f 100644 --- a/test/hydration/samples/element-attribute-changed/_config.js +++ b/test/hydration/samples/element-attribute-changed/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { class: 'bar' }, diff --git a/test/hydration/samples/element-attribute-removed/_config.js b/test/hydration/samples/element-attribute-removed/_config.js index a1cfe933c2..05881f748f 100644 --- a/test/hydration/samples/element-attribute-removed/_config.js +++ b/test/hydration/samples/element-attribute-removed/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { class: 'bar' }, diff --git a/test/hydration/samples/element-ref/main.html b/test/hydration/samples/element-ref/main.html index 95c0299762..bf046f16b1 100644 --- a/test/hydration/samples/element-ref/main.html +++ b/test/hydration/samples/element-ref/main.html @@ -1 +1,5 @@ + +

Hello world!

\ No newline at end of file diff --git a/test/hydration/samples/event-handler/_config.js b/test/hydration/samples/event-handler/_config.js index d231e1fd0d..cdf7431836 100644 --- a/test/hydration/samples/event-handler/_config.js +++ b/test/hydration/samples/event-handler/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { clicked: false }, diff --git a/test/hydration/samples/if-block-anchor/_config.js b/test/hydration/samples/if-block-anchor/_config.js index f9acaa30ed..ee5ed39ad9 100644 --- a/test/hydration/samples/if-block-anchor/_config.js +++ b/test/hydration/samples/if-block-anchor/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { foo: true, bar: true }, diff --git a/test/hydration/samples/if-block-false/_config.js b/test/hydration/samples/if-block-false/_config.js index ba071e9910..6be30614f8 100644 --- a/test/hydration/samples/if-block-false/_config.js +++ b/test/hydration/samples/if-block-false/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { foo: false }, diff --git a/test/hydration/samples/if-block-update/_config.js b/test/hydration/samples/if-block-update/_config.js index 185dacb1e7..75d056e04d 100644 --- a/test/hydration/samples/if-block-update/_config.js +++ b/test/hydration/samples/if-block-update/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { foo: true, bar: false }, @@ -17,7 +17,8 @@ export default { assert.equal(p, snapshot.p); - component.set({ foo: false, bar: true }); + component.foo = false; + component.bar = true; assert.htmlEqual(target.innerHTML, `

bar!

`); } }; \ No newline at end of file diff --git a/test/hydration/samples/if-block/_config.js b/test/hydration/samples/if-block/_config.js index 465c32c2af..7aca2ce55d 100644 --- a/test/hydration/samples/if-block/_config.js +++ b/test/hydration/samples/if-block/_config.js @@ -1,5 +1,5 @@ export default { - data: { + props: { foo: true }, diff --git a/test/hydration/samples/raw/_config.js b/test/hydration/samples/raw/_config.js index e1108714ee..4af36b099e 100644 --- a/test/hydration/samples/raw/_config.js +++ b/test/hydration/samples/raw/_config.js @@ -1,7 +1,7 @@ export default { skip: true, // existing nodes are blown away - data: { + props: { raw: `

this is some html

and so is this

` },