fix remove extra store subscription statement

pull/5929/head
Tan Li Hau 6 years ago
parent 94439ef5e7
commit a251d2f073

@ -51,7 +51,6 @@ export default function ssr(
return b`
${component.compile_options.dev && b`@validate_store(${store_name}, '${store_name}');`}
${`$$unsubscribe_${store_name}`} = @subscribe(${store_name}, #value => ${name} = #value)
${store_name}.subscribe($$value => ${name} = $$value);
`;
});
const reactive_store_unsubscriptions = reactive_stores.map(

@ -0,0 +1,20 @@
import { store } from './store.js';
export default {
html: '<h1>0</h1>',
before_test() {
store.reset();
},
async test({ assert, target, component }) {
store.set(42);
await Promise.resolve();
assert.htmlEqual(target.innerHTML, '<h1>42</h1>');
assert.equal(store.numberOfTimesSubscribeCalled(), 1);
},
test_ssr({ assert }) {
assert.equal(store.numberOfTimesSubscribeCalled(), 1);
}
};

@ -0,0 +1,5 @@
<script>
import { store } from './store';
</script>
<h1>{$store}</h1>

@ -0,0 +1,18 @@
import { writable } from '../../../../store';
const _store = writable(0);
let count = 0;
export const store = {
..._store,
subscribe(fn) {
count++;
return _store.subscribe(fn);
},
reset() {
count = 0;
_store.set(0);
},
numberOfTimesSubscribeCalled() {
return count;
}
};

@ -197,6 +197,10 @@ describe('ssr', () => {
assert.htmlEqual(html, config.html);
}
if (config.test_ssr) {
config.test_ssr({ assert });
}
if (config.after_test) config.after_test();
if (config.show) {

Loading…
Cancel
Save