-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathbadges-test.js
37 lines (29 loc) · 1.22 KB
/
badges-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { render } from '@1024pix/ember-testing-library';
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering';
module('Integration | Component | Campaign::Badges', function (hooks) {
setupIntlRenderingTest(hooks);
test('should render badge images for each one', async function (assert) {
// given
this.badges = [
{ title: 'badge1', imageUrl: 'img1', altMessage: 'alt-img1' },
{ title: 'badge2', imageUrl: 'img2', altMessage: 'alt-img2' },
];
// when
await render(hbs`<Campaign::Badges @badges={{this.badges}} />`);
// then
const badgeImages = this.element.querySelectorAll('img');
assert.strictEqual(badgeImages.length, 2);
assert.strictEqual(badgeImages[0].getAttribute('src'), 'img1');
assert.strictEqual(badgeImages[0].getAttribute('alt'), 'alt-img1');
});
test('should render the title', async function (assert) {
// given
this.badges = [{ title: 'badge1', imageUrl: 'img1', altMessage: 'alt-img1' }];
// when
const screen = await render(hbs`<Campaign::Badges @badges={{this.badges}} />`);
// then
assert.ok(screen.getByText('badge1'));
});
});