|
1 | 1 | import { render } from '@ember/test-helpers'; |
2 | | -import { module, skip, test } from 'qunit'; |
| 2 | +import { module, test } from 'qunit'; |
3 | 3 | import { setupRenderingTest } from 'ember-qunit'; |
4 | 4 | import hbs from 'htmlbars-inline-precompile'; |
5 | 5 |
|
6 | | -module('Integration | Component | es ulist', function(hooks){ |
| 6 | +function generateList(number) { |
| 7 | + return new Array(number).fill({ |
| 8 | + text: 'Hakubo was here', |
| 9 | + link: 'emberjs.com', |
| 10 | + image: 'https://emberjs.com/images/tomsters/atlanta-zoey-38822a67.png', |
| 11 | + }); |
| 12 | +} |
| 13 | + |
| 14 | +module('Integration | Component | es ulist', function(hooks) { |
7 | 15 | setupRenderingTest(hooks); |
8 | 16 |
|
9 | 17 | test('it renders', async function(assert) { |
| 18 | + await render(hbs`<EsUlist @listTitle="Zoey by City"/>`); |
10 | 19 |
|
11 | | - // Set any properties with this.set('myProperty', 'value'); |
12 | | - // Handle any actions with this.on('myAction', function(val) { ... }); |
13 | | - |
14 | | - await render(hbs`{{es-ulist}}`); |
15 | | - |
16 | | - assert.dom('*').hasText(''); |
| 20 | + assert.dom('.list-title').hasText('Zoey by City'); |
| 21 | + assert.dom('.list').exists(); |
17 | 22 | }); |
18 | 23 |
|
19 | | - skip('the list is populated', function(){ |
| 24 | + test('the list is populated', async function(assert) { |
| 25 | + this.set('listItems', generateList(2)); |
20 | 26 |
|
| 27 | + await render(hbs` |
| 28 | + <EsUlist |
| 29 | + @listItems={{listItems}} |
| 30 | + /> |
| 31 | + `); |
| 32 | + |
| 33 | + assert.dom('.list-item').exists({ count: 2 }); |
| 34 | + assert.dom('.list-item:first-child').hasText('Hakubo was here'); |
21 | 35 | }); |
22 | 36 |
|
23 | | - skip('a list with images renders the images correctly', function(){ |
| 37 | + test('a list with images renders the images correctly', async function(assert) { |
| 38 | + this.set('listItems', generateList(1)); |
| 39 | + |
| 40 | + await render(hbs` |
| 41 | + <EsUlist |
| 42 | + @listItems={{listItems}} |
| 43 | + @hasImage={{true}} |
| 44 | + /> |
| 45 | + `); |
24 | 46 |
|
| 47 | + assert |
| 48 | + .dom('.list-item-image') |
| 49 | + .hasAttribute( |
| 50 | + 'src', |
| 51 | + 'https://emberjs.com/images/tomsters/atlanta-zoey-38822a67.png', |
| 52 | + ); |
25 | 53 | }); |
26 | 54 |
|
27 | | - skip('the id value of the list title matches the value in the aria-describedby property on the list element', function(){ |
| 55 | + test('the id value of the list title matches the value in the aria-describedby property on the list element', async function(assert) { |
| 56 | + await render(hbs`<EsUlist @elementId="test" />`); |
28 | 57 |
|
| 58 | + assert.dom('.list').hasAttribute('aria-labelledby', 'list-test') |
| 59 | + assert.dom('.list-title').hasAttribute('id', 'list-test'); |
29 | 60 | }); |
30 | 61 |
|
31 | | - skip('when hasLink is set to true, a link element renders', function(){ |
| 62 | + test('when @hasLink is set to true, a link element renders', async function(assert) { |
| 63 | + this.set('listItems', generateList(1)); |
| 64 | + |
| 65 | + await render(hbs` |
| 66 | + <EsUlist |
| 67 | + @listTitle="Zoey by City" |
| 68 | + @listItems={{listItems}} |
| 69 | + @hasLink={{true}} |
| 70 | + /> |
| 71 | + `); |
32 | 72 |
|
| 73 | + assert.dom('.list-item-link').hasAttribute('href', 'emberjs.com'); |
33 | 74 | }); |
34 | 75 | }); |
0 commit comments