diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index a8775d41b2..99f7597276 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -536,6 +536,9 @@ export default class Generator { (param: Node) => param.type === 'AssignmentPattern' ? param.left.name : param.name ); + deps.forEach(dep => { + this.expectedProperties.add(dep); + }); dependencies.set(key, deps); }); diff --git a/test/runtime/samples/store-computed/Todo.html b/test/runtime/samples/store-computed/Todo.html new file mode 100644 index 0000000000..2ad67420ca --- /dev/null +++ b/test/runtime/samples/store-computed/Todo.html @@ -0,0 +1,15 @@ +{{#if isVisible}} +
{{todo.description}}
+{{/if}} + + \ No newline at end of file diff --git a/test/runtime/samples/store-computed/_config.js b/test/runtime/samples/store-computed/_config.js new file mode 100644 index 0000000000..2906ff4bf8 --- /dev/null +++ b/test/runtime/samples/store-computed/_config.js @@ -0,0 +1,65 @@ +import Store from '../../../../store.js'; + +class MyStore extends Store { + setFilter(filter) { + this.set({ filter }); + } + + toggleTodo(todo) { + todo.done = !todo.done; + this.set({ todos: this.get('todos') }); + } +} + +const todos = [ + { + description: 'Buy some milk', + done: true, + }, + { + description: 'Do the laundry', + done: true, + }, + { + description: "Find life's true purpose", + done: false, + } +]; + +const store = new MyStore({ + filter: 'all', + todos +}); + +export default { + solo: true, + + store, + + html: ` +
Buy some milk
+
Do the laundry
+
Find life's true purpose
+ `, + + test(assert, component, target) { + store.setFilter('pending'); + + assert.htmlEqual(target.innerHTML, ` +
Find life's true purpose
+ `); + + store.toggleTodo(todos[1]); + + assert.htmlEqual(target.innerHTML, ` +
Do the laundry
+
Find life's true purpose
+ `); + + store.setFilter('done'); + + assert.htmlEqual(target.innerHTML, ` +
Buy some milk
+ `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/store-computed/main.html b/test/runtime/samples/store-computed/main.html new file mode 100644 index 0000000000..5c50839ba3 --- /dev/null +++ b/test/runtime/samples/store-computed/main.html @@ -0,0 +1,11 @@ +{{#each $todos as todo}} + +{{/each}} + + \ No newline at end of file