1
0
Fork 0
sortable-recipes/ember-ui/tests/integration/components/recipe-preview-test.js
2019-12-27 22:51:18 -06:00

54 lines
1.7 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | recipe-preview', function(hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
hooks.beforeEach(initMeal);
test('it renders a wrapper href', async function(assert) {
await render(hbs`<RecipePreview @meal={{meal}} />`);
assert.dom('[data-test-id=recipe-link]').hasTagName('a');
});
test('it renders recipe preview image', async function(assert) {
await render(hbs`<RecipePreview @meal={{meal}} />`);
assert.dom('[data-test-id=recipe-preview-image]').hasAttribute('src', 'image.jpg');
});
test('it renders recipe data as text', async function(assert) {
await render(hbs`<RecipePreview @meal={{meal}} />`);
assert.dom('[data-test-id=recipe-name]').hasText('Cookies');
assert.dom('[data-test-id=recipe-ingredients-list]').hasText('Love, Chocolate');
assert.dom('[data-test-id=recipe-tags]').includesText('Home');
assert.dom('[data-test-id=recipe-tags]').includesText('Desserts');
});
async function initMeal() {
let store = this.owner.lookup('service:store');
this.server.create('meal', {
area: 'Home',
category: 'Desserts',
id: 1,
ingredients: [
{
name: 'Love',
measure: 'Infinity',
}, {
name: 'Chocolate',
measure: 'As Much As You Desire',
},
],
name: 'Cookies',
thumbnailUrl: 'image.jpg',
});
this.set('meal', await store.findRecord('meal', 1));
}
});