|
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 | 6 | module('Integration | Component | es ulist', function(hooks){
|
7 | 7 | setupRenderingTest(hooks);
|
8 | 8 |
|
9 |
| - test('it renders', async function(assert) { |
| 9 | + test('it renders with border', async function(assert) { |
10 | 10 |
|
11 |
| - // Set any properties with this.set('myProperty', 'value'); |
12 |
| - // Handle any actions with this.on('myAction', function(val) { ... }); |
| 11 | + await render(hbs`{{es-ulist hasBorder=true}}`); |
13 | 12 |
|
14 |
| - await render(hbs`{{es-ulist}}`); |
| 13 | + assert.dom('.es-ulist').hasClass('bordered'); |
15 | 14 |
|
16 |
| - assert.dom('*').hasText(''); |
17 | 15 | });
|
18 | 16 |
|
19 |
| - skip('the list is populated', function(){ |
| 17 | + module('Title', function () { |
| 18 | + test('it renders the title with correct id', async function(assert) { |
| 19 | + assert.expect(2); |
20 | 20 |
|
21 |
| - }); |
| 21 | + await render(hbs`{{es-ulist elementId="mylist" listTitle="My List Title"}}`); |
22 | 22 |
|
23 |
| - skip('a list with images renders the images correctly', function(){ |
| 23 | + assert.dom('#mylist').hasText('My List Title'); |
| 24 | + assert.dom('.es-ulist').doesNotHaveClass('bordered'); |
| 25 | + }); |
24 | 26 |
|
25 |
| - }); |
| 27 | + test('it renders the title with sr-only class when isTitleVisible is true', async function(assert) { |
| 28 | + assert.expect(2); |
26 | 29 |
|
27 |
| - skip('the id value of the list title matches the value in the aria-describedby property on the list element', function(){ |
| 30 | + await render(hbs`{{es-ulist isTitleVisible=true sr-only="srClass" elementId="mylist" listTitle="My List Title"}}`); |
28 | 31 |
|
29 |
| - }); |
| 32 | + assert.dom('#list-mylist').hasClass('list-title'); |
| 33 | + assert.dom('#list-mylist').hasClass('srClass'); |
| 34 | + }); |
| 35 | + |
| 36 | + test('it renders the title without sr-only class when isTitleVisible is false', async function(assert) { |
| 37 | + assert.expect(2); |
30 | 38 |
|
31 |
| - skip('when hasLink is set to true, a link element renders', function(){ |
| 39 | + await render(hbs`{{es-ulist isTitleVisible=false sr-only="srClass" elementId="mylist" listTitle="My List Title"}}`); |
| 40 | + |
| 41 | + assert.dom('#list-mylist').hasClass('list-title'); |
| 42 | + assert.dom('#list-mylist').doesNotHaveClass('srClass'); |
| 43 | + }); |
32 | 44 |
|
33 | 45 | });
|
| 46 | + |
| 47 | + module('List', function () { |
| 48 | + module('Ordered List', function () { |
| 49 | + |
| 50 | + test('the list does not have unorderded items', async function(assert){ |
| 51 | + assert.expect(1); |
| 52 | + |
| 53 | + await render(hbs`{{es-ulist isUnorderedList=false}}`); |
| 54 | + |
| 55 | + assert.dom('.es-ulist ul').doesNotExist(); |
| 56 | + }); |
| 57 | + |
| 58 | + }); |
| 59 | + module('Unordered List', function () { |
| 60 | + |
| 61 | + test('the id value of the list title matches the value in the aria-labelledby property on the list element', async function(assert){ |
| 62 | + assert.expect(2); |
| 63 | + |
| 64 | + await render(hbs`{{es-ulist elementId='mylist' isUnorderedList=true}}`); |
| 65 | + |
| 66 | + assert.dom('.es-ulist ul').hasAttribute('aria-labelledby', 'list-mylist'); |
| 67 | + assert.dom('.list-title').hasAttribute('id', 'list-mylist'); |
| 68 | + |
| 69 | + }); |
| 70 | + |
| 71 | + test('the list does not have ordered items', async function(assert){ |
| 72 | + assert.expect(1); |
| 73 | + |
| 74 | + await render(hbs`{{es-ulist isUnorderedList=false}}`); |
| 75 | + |
| 76 | + assert.dom('.es-ulist ol').doesNotExist(); |
| 77 | + }); |
| 78 | + |
| 79 | + module('With items', function (hooks) { |
| 80 | + let listItems; |
| 81 | + hooks.beforeEach(function () { |
| 82 | + listItems = [ |
| 83 | + { |
| 84 | + text: 'item 1', |
| 85 | + image: '/images/tomsters/columbus.png', |
| 86 | + alt: 'Columbus' |
| 87 | + }, |
| 88 | + { |
| 89 | + text: 'item 2', |
| 90 | + link: 'http://emberjs.com' |
| 91 | + }, |
| 92 | + { |
| 93 | + text: 'item 3', |
| 94 | + link: 'http://guides.emberjs.com', |
| 95 | + image: '/images/tomsters/chicago.png', |
| 96 | + alt: 'Chicago' |
| 97 | + }, |
| 98 | + ] |
| 99 | + this.set('listItems', listItems); |
| 100 | + }); |
| 101 | + |
| 102 | + test('the list has correct aria label and classes', async function(assert){ |
| 103 | + assert.expect(3); |
| 104 | + |
| 105 | + await render(hbs`{{es-ulist elementId='mylist' isUnorderedList=true}}`); |
| 106 | + |
| 107 | + assert.dom('.es-ulist ul').hasAttribute('aria-labelledby', 'list-mylist'); |
| 108 | + assert.dom('.es-ulist ul').hasClass('list'); |
| 109 | + assert.dom('.es-ulist ul').hasClass('list-default'); |
| 110 | + |
| 111 | + }); |
| 112 | + |
| 113 | + test('the list is populated', async function(assert){ |
| 114 | + assert.expect(14); |
| 115 | + |
| 116 | + await render(hbs`{{es-ulist isUnorderedList=true listItems=listItems}}`); |
| 117 | + |
| 118 | + assert.dom('.es-ulist ul li').exists({count: 3}); |
| 119 | + assert.dom('.es-ulist ul li:nth-child(1) img').hasAttribute('src', '/images/tomsters/columbus.png'); |
| 120 | + assert.dom('.es-ulist ul li:nth-child(1) img').hasAttribute('alt', 'Columbus'); |
| 121 | + assert.dom('.es-ulist ul li:nth-child(1) img').hasClass('list-item-image'); |
| 122 | + assert.dom('.es-ulist ul li:nth-child(1)').hasText('item 1'); |
| 123 | + |
| 124 | + assert.dom('.es-ulist ul li:nth-child(2) a').hasAttribute('href', 'http://emberjs.com'); |
| 125 | + assert.dom('.es-ulist ul li:nth-child(2) a').hasClass('list-item-link'); |
| 126 | + assert.dom('.es-ulist ul li:nth-child(2)').hasText('item 2'); |
| 127 | + |
| 128 | + assert.dom('.es-ulist ul li:nth-child(3) a').hasAttribute('href', 'http://guides.emberjs.com'); |
| 129 | + assert.dom('.es-ulist ul li:nth-child(3) img').hasAttribute('src', '/images/tomsters/chicago.png'); |
| 130 | + assert.dom('.es-ulist ul li:nth-child(3) img').hasAttribute('alt', 'Chicago'); |
| 131 | + assert.dom('.es-ulist ul li:nth-child(3) img').hasClass('list-item-image'); |
| 132 | + assert.dom('.es-ulist ul li:nth-child(3) a').hasClass('list-item-link'); |
| 133 | + assert.dom('.es-ulist ul li:nth-child(3)').hasText('item 3'); |
| 134 | + |
| 135 | + }); |
| 136 | + }); |
| 137 | + |
| 138 | + }); |
| 139 | + }) |
34 | 140 | });
|
0 commit comments