diff --git a/app/components/recipe-add.hbs b/app/components/recipe-add.hbs new file mode 100644 index 0000000..02d1b19 --- /dev/null +++ b/app/components/recipe-add.hbs @@ -0,0 +1,5 @@ + diff --git a/app/components/recipe-add.js b/app/components/recipe-add.js new file mode 100644 index 0000000..b8a5518 --- /dev/null +++ b/app/components/recipe-add.js @@ -0,0 +1,17 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import { task } from 'ember-concurrency'; +import { action } from "@ember/object"; + +export default class RecipeAddComponent extends Component { + @service store; + + @(task(function * () { + return yield this.store.queryRecord('meal', 'random'); + })) fetchRecipe; + + @action + async addRecipe() { + await this.fetchRecipe.perform(); + } +} diff --git a/app/components/recipe-list.hbs b/app/components/recipe-list.hbs index 12a6053..b11064a 100644 --- a/app/components/recipe-list.hbs +++ b/app/components/recipe-list.hbs @@ -1,20 +1,16 @@ - - {{#each group.model as |meal|}} - - - - - - {{/each}} - - - +
+ + {{#each group.model as |meal|}} + + + + + + {{/each}} + +
diff --git a/app/components/recipe-list.js b/app/components/recipe-list.js index adca2ea..faf2707 100644 --- a/app/components/recipe-list.js +++ b/app/components/recipe-list.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { tracked } from "@glimmer/tracking"; import { action } from "@ember/object"; import { A } from '@ember/array'; -import { task } from 'ember-concurrency'; import { inject as service } from '@ember/service'; export default class RecipeListComponent extends Component { @@ -19,17 +18,8 @@ export default class RecipeListComponent extends Component { this.items = items; } - @(task(function * () { - return yield this.store.queryRecord('meal', 'random'); - })) fetchRecipe; - @action reorderItems(reorderedItems) { this.items = reorderedItems; } - - @action - async addRecipe() { - await this.fetchRecipe.perform(); - } } diff --git a/app/templates/application.hbs b/app/templates/application.hbs index fb86a52..86e6336 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -3,6 +3,7 @@
+
{{outlet}} diff --git a/tests/integration/components/recipe-add-test.js b/tests/integration/components/recipe-add-test.js new file mode 100644 index 0000000..fcdd6bc --- /dev/null +++ b/tests/integration/components/recipe-add-test.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | recipe-add', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function(assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.equal(this.element.textContent.trim(), ''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.equal(this.element.textContent.trim(), 'template block text'); + }); +});