update immutability test, though may need to be skipped for now

pull/1864/head
Rich Harris 7 years ago
parent ed39c85f5d
commit be59af940b

@ -1,6 +0,0 @@
<script>
export let count = 0;
export let foo = { bar: 'baz' };
</script>
<h3>Called {count} times.</h3>

@ -1,18 +0,0 @@
export default {
immutable: true,
html: `<div><h3>Called 0 times.</h3></div>`,
test(assert, component, target, window) {
var nested = component.nested;
nested.on('state', ({ changed }) => {
if (changed.foo) {
nested.set({ count: nested.get().count + 1 });
}
});
assert.htmlEqual(target.innerHTML, `<div><h3>Called 0 times.</h3></div>`);
nested.set({ foo: nested.get().foo });
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`);
}
};

@ -1,9 +0,0 @@
<script>
export let nested;
import Nested from './Nested.html';
</script>
<div>
<Nested ref:nested />
</div>

@ -1,6 +1,17 @@
<script>
import { beforeRender, onMount } from 'svelte';
let mounted;
export let count = 0;
export let foo = { bar: 'baz' };
onMount(() => {
mounted = true;
});
beforeRender(() => {
if (mounted) count += 1;
});
</script>
<h3>Called {count} times.</h3>

@ -1,18 +1,13 @@
export default {
immutable: true,
html: `<div><h3>Called 0 times.</h3></div>`,
html: `<div><h3>Called 1 times.</h3></div>`,
test(assert, component, target, window) {
var nested = component.nested;
nested.on('state', ({ changed }) => {
if (changed.foo) {
nested.set({ count: nested.get().count + 1 });
}
});
assert.htmlEqual(target.innerHTML, `<div><h3>Called 0 times.</h3></div>`);
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`);
nested.set({ foo: nested.get().foo });
assert.htmlEqual(target.innerHTML, `<div><h3>Called 0 times.</h3></div>`);
nested.foo = nested.foo;
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`);
}
};

Loading…
Cancel
Save