Skip to content

Commit e48f413

Browse files
authored
Merge pull request #371 from Turbo87/qunit-dom
Use "qunit-dom" plugin
2 parents 938b51d + 8d294f6 commit e48f413

File tree

9 files changed

+79
-71
lines changed

9 files changed

+79
-71
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@
8585
"fastboot-app-server": "^1.0.1",
8686
"loader.js": "^4.6.0",
8787
"minimist": "^1.2.0",
88-
"normalize.css": "^7.0.0"
88+
"normalize.css": "^7.0.0",
89+
"qunit-dom": "^0.3.2"
8990
},
9091
"engines": {
9192
"node": "8",

tests/acceptance/app-layout-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ test('lists the project versions in a select box', async function(assert) {
99

1010
await selectSearch('.select-container', '2');
1111

12-
assert.equal(find('.ember-power-select-options').length, 1);
12+
assert.dom('.ember-power-select-options').exists({ count: 1 });
1313
assert.ok(find('.ember-power-select-options')[0].children.length > 1);
1414
});

tests/acceptance/method-inheritance-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-acceptance';
22
import {skip} from 'qunit';
3-
import { visit, click, findAll, findWithAssert } from 'ember-native-dom-helpers';
3+
import { visit, click, findWithAssert } from 'ember-native-dom-helpers';
44
import testSelector from 'ember-test-selectors';
55

66
moduleForAcceptance('Acceptance | method inheritance')
77

88
skip('no duplicate methods displayed', async function (assert) {
99
await visit('/ember-data/2.14/classes/DS.JSONAPIAdapter');
10-
assert.equal(findAll("[data-test-item='createRecord']").length, 1);
10+
assert.dom("[data-test-item='createRecord']").exists({ count: 1 });
1111
});
1212

1313
skip('most local inherited method is shown', async function (assert) {

tests/acceptance/switch-project-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ skip('Can switch projects back and forth', async function(assert) {
1414
async function ensureVersionsExist() {
1515
await selectSearch('.select-container', '2');
1616

17-
assert.equal(findAll('.ember-power-select-options').length, 1);
17+
assert.dom('.ember-power-select-options').exists({ count: 1 });
1818
assert.ok(findAll('.ember-power-select-options')[0].children.length > 1);
1919
}
2020

tests/integration/components/api-index-filter-test.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ test('clicking inherited shows inherited methods', async function(assert) {
110110
`);
111111

112112
await click('#inherited-toggle');
113-
assert.equal(findAll('.method-name').length, 2, 'should display 2 methods total');
114-
assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
115-
assert.equal(findAll('.method-name')[1].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method');
113+
assert.dom('.method-name').exists({ count: 2 }, 'should display 2 methods total');
114+
assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method');
115+
assert.dom(findAll('.method-name')[1]).hasText('parentDoSomething', 'should display 1 inherited method');
116116
});
117117

118118
test('clicking private shows private methods', async function(assert) {
@@ -169,9 +169,9 @@ test('clicking private shows private methods', async function(assert) {
169169
`);
170170

171171
await click('#private-toggle');
172-
assert.equal(findAll('.method-name').length, 2, 'should display 2 methods total');
173-
assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
174-
assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method');
172+
assert.dom('.method-name').exists({ count: 2 }, 'should display 2 methods total');
173+
assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method');
174+
assert.dom(findAll('.method-name')[1]).hasText('doSomethingPrivate', 'should display 1 private method');
175175
});
176176

177177
test('clicking private and inherited shows both methods', async function(assert) {
@@ -229,10 +229,10 @@ test('clicking private and inherited shows both methods', async function(assert)
229229

230230
await click('#private-toggle');
231231
await click('#inherited-toggle');
232-
assert.equal(findAll('.method-name').length, 3, 'should display 3 methods total');
233-
assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
234-
assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method');
235-
assert.equal(findAll('.method-name')[2].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method');
232+
assert.dom('.method-name').exists({ count: 3 }, 'should display 3 methods total');
233+
assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method');
234+
assert.dom(findAll('.method-name')[1]).hasText('doSomethingPrivate', 'should display 1 private method');
235+
assert.dom(findAll('.method-name')[2]).hasText('parentDoSomething', 'should display 1 inherited method');
236236
});
237237

238238

@@ -293,12 +293,12 @@ test('clicking all toggles shows all methods', async function(assert) {
293293
await click('#inherited-toggle');
294294
await click('#protected-toggle');
295295
await click('#deprecated-toggle');
296-
assert.equal(findAll('.method-name').length, 5, 'should display all methods');
297-
assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
298-
assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingDeprecated', 'should display 1 deprecated method');
299-
assert.equal(findAll('.method-name')[2].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method');
300-
assert.equal(findAll('.method-name')[3].textContent.trim(), 'doSomethingProtected', 'should display 1 protected method');
301-
assert.equal(findAll('.method-name')[4].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method');
296+
assert.dom('.method-name').exists({ count: 5 }, 'should display all methods');
297+
assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method');
298+
assert.dom(findAll('.method-name')[1]).hasText('doSomethingDeprecated', 'should display 1 deprecated method');
299+
assert.dom(findAll('.method-name')[2]).hasText('doSomethingPrivate', 'should display 1 private method');
300+
assert.dom(findAll('.method-name')[3]).hasText('doSomethingProtected', 'should display 1 protected method');
301+
assert.dom(findAll('.method-name')[4]).hasText('parentDoSomething', 'should display 1 inherited method');
302302
});
303303

304304

@@ -355,19 +355,19 @@ test('clicking all toggles off should only show public', async function(assert)
355355
{{/api-index-filter}}
356356
`);
357357

358-
assert.equal(findAll('.method-name').length, 5, 'should display all methods');
359-
assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
360-
assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingDeprecated', 'should display 1 deprecated method');
361-
assert.equal(findAll('.method-name')[2].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method');
362-
assert.equal(findAll('.method-name')[3].textContent.trim(), 'doSomethingProtected', 'should display 1 protected method');
363-
assert.equal(findAll('.method-name')[4].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method');
358+
assert.dom('.method-name').exists({ count: 5 }, 'should display all methods');
359+
assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method');
360+
assert.dom(findAll('.method-name')[1]).hasText('doSomethingDeprecated', 'should display 1 deprecated method');
361+
assert.dom(findAll('.method-name')[2]).hasText('doSomethingPrivate', 'should display 1 private method');
362+
assert.dom(findAll('.method-name')[3]).hasText('doSomethingProtected', 'should display 1 protected method');
363+
assert.dom(findAll('.method-name')[4]).hasText('parentDoSomething', 'should display 1 inherited method');
364364

365365
await click('#private-toggle');
366366
await click('#inherited-toggle');
367367
await click('#protected-toggle');
368368
await click('#deprecated-toggle');
369369

370-
assert.equal(findAll('.method-name').length, 1, 'should display all methods');
371-
assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
370+
assert.dom('.method-name').exists({ count: 1 }, 'should display all methods');
371+
assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method');
372372

373373
});

tests/integration/components/api-index-test.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import EmberObject from '@ember/object';
22
import { moduleForComponent, test } from 'ember-qunit';
33
import hbs from 'htmlbars-inline-precompile';
4-
import { click, findAll, find } from 'ember-native-dom-helpers';
4+
import { click, findAll } from 'ember-native-dom-helpers';
55

66
moduleForComponent('api-index', 'Integration | Component | api index', {
77
integration: true
@@ -63,13 +63,13 @@ test('should display api index', function (assert) {
6363
{{/each}}
6464
{{/api-index}}
6565
`);
66-
assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections');
67-
assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section');
68-
assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section');
69-
assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section');
70-
assert.equal(find('.spec-method-list>li>a').textContent.trim(), 'doSomething', 'should display 1 method');
71-
assert.equal(find('.spec-property-list>li>a').textContent.trim(), 'isSomething', 'should display 1 property');
72-
assert.equal(find('.spec-event-list>li>a').textContent.trim(), 'didSomething', 'should display 1 event');
66+
assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections');
67+
assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section');
68+
assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section');
69+
assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section');
70+
assert.dom('.spec-method-list>li>a').hasText('doSomething', 'should display 1 method');
71+
assert.dom('.spec-property-list>li>a').hasText('isSomething', 'should display 1 property');
72+
assert.dom('.spec-event-list>li>a').hasText('didSomething', 'should display 1 event');
7373
});
7474

7575
test('should display text when no methods', function (assert) {
@@ -123,13 +123,13 @@ test('should display text when no methods', function (assert) {
123123
{{/each}}
124124
{{/api-index}}
125125
`);
126-
assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections');
127-
assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section');
128-
assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section');
129-
assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section');
130-
assert.equal(find('.spec-method-list').textContent.trim(), 'No documented items', 'should display no items text');
131-
assert.equal(find('.spec-property-list').textContent.trim(), 'isSomething', 'should display 1 property');
132-
assert.equal(find('.spec-event-list').textContent.trim(), 'didSomething', 'should display 1 event');
126+
assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections');
127+
assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section');
128+
assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section');
129+
assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section');
130+
assert.dom('.spec-method-list').hasText('No documented items', 'should display no items text');
131+
assert.dom('.spec-property-list').hasText('isSomething', 'should display 1 property');
132+
assert.dom('.spec-event-list').hasText('didSomething', 'should display 1 event');
133133
});
134134

135135
test('should display api index with filter', function (assert) {
@@ -253,13 +253,13 @@ test('should display api index with filter', function (assert) {
253253
{{/api-index}}
254254
{{/api-index-filter}}
255255
`);
256-
assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections');
257-
assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section');
258-
assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section');
259-
assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section');
260-
assert.equal(find('.spec-method-list').textContent.trim(), 'doSomething', 'should display 1 method');
261-
assert.equal(find('.spec-property-list').textContent.trim(), 'isSomething', 'should display 1 property');
262-
assert.equal(find('.spec-event-list').textContent.trim(), 'didSomething', 'should display 1 event');
256+
assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections');
257+
assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section');
258+
assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section');
259+
assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section');
260+
assert.dom('.spec-method-list').hasText('doSomething', 'should display 1 method');
261+
assert.dom('.spec-property-list').hasText('isSomething', 'should display 1 property');
262+
assert.dom('.spec-event-list').hasText('didSomething', 'should display 1 event');
263263
});
264264

265265

@@ -382,17 +382,17 @@ test('should display inherited method when show inherited toggled on', async fun
382382
{{/api-index}}
383383
{{/api-index-filter}}
384384
`);
385-
assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections');
386-
assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section');
387-
assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section');
388-
assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section');
389-
assert.equal(find('.spec-method-list>li>a').textContent.trim(), 'doSomething', 'should display 1 method');
390-
assert.equal(find('.spec-property-list>li>a').textContent.trim(), 'isSomething', 'should display 1 property');
391-
assert.equal(find('.spec-event-list>li>a').textContent.trim(), 'didSomething', 'should display 1 event');
385+
assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections');
386+
assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section');
387+
assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section');
388+
assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section');
389+
assert.dom('.spec-method-list>li>a').hasText('doSomething', 'should display 1 method');
390+
assert.dom('.spec-property-list>li>a').hasText('isSomething', 'should display 1 property');
391+
assert.dom('.spec-event-list>li>a').hasText('didSomething', 'should display 1 event');
392392

393393
await click('#inherited-toggle');
394394

395-
assert.equal(findAll('.spec-method-list>li>a').length, 2, 'should display 2 methods total');
396-
assert.equal(findAll('.spec-method-list>li>a')[0].textContent.trim(), 'doSomething', 'should display 1 public method');
397-
assert.equal(findAll('.spec-method-list>li>a')[1].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method');
395+
assert.dom('.spec-method-list>li>a').exists({ count: 2 }, 'should display 2 methods total');
396+
assert.dom(findAll('.spec-method-list>li>a')[0]).hasText('doSomething', 'should display 1 public method');
397+
assert.dom(findAll('.spec-method-list>li>a')[1]).hasText('parentDoSomething', 'should display 1 inherited method');
398398
});

tests/integration/components/class-field-description-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import EmberObject from '@ember/object';
22
import { moduleForComponent, test } from 'ember-qunit';
33
import hbs from 'htmlbars-inline-precompile';
4-
import { find, findAll, triggerEvent } from 'ember-native-dom-helpers';
4+
import { findAll, triggerEvent } from 'ember-native-dom-helpers';
55

66
moduleForComponent('class-field-description', 'Integration | Component | class field description', {
77
integration: true
@@ -19,10 +19,10 @@ test('it renders', function(assert) {
1919

2020
this.render(hbs`{{class-field-description type=type field=field}}`);
2121

22-
assert.equal(find('.method-name').textContent.trim(), 'concat');
23-
assert.equal(findAll('.access')[0].textContent.trim(), 'public');
24-
assert.equal(findAll('.access')[1].textContent.trim(), 'deprecated');
25-
assert.equal(findAll('.args')[0].textContent.trim(), '(param1, param2, param3)');
22+
assert.dom('.method-name').hasText('concat');
23+
assert.dom(findAll('.access')[0]).hasText('public');
24+
assert.dom(findAll('.access')[1]).hasText('deprecated');
25+
assert.dom(findAll('.args')[0]).hasText('(param1, param2, param3)');
2626
});
2727

2828

@@ -39,5 +39,5 @@ test('On hover -- the link icon shows up', async function(assert) {
3939
this.render(hbs`{{class-field-description type=type field=field}}`);
4040

4141
await triggerEvent('.class-field-description--link', 'mouseenter');
42-
assert.ok(find('.class-field-description--link-hover'), 'The link icon appears when hovering on the method text');
42+
assert.dom('.class-field-description--link-hover').exists('The link icon appears when hovering on the method text');
4343
});

tests/integration/components/table-of-contents-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ skip('it renders', function(assert) {
2222
classesIDs=classesIDs
2323
}}`);
2424

25-
assert.equal(findAll('.toc-level-0 > a')[2].textContent.trim(), 'Classes');
26-
assert.equal(findAll('.toc-level-1 li').length, 2, 'We have two items to display');
27-
assert.equal(findAll('.toc-level-1 li')[0].textContent.trim(), 'Descriptor');
28-
assert.equal(findAll('.toc-level-1 li')[1].textContent.trim(), 'Ember');
25+
assert.dom(findAll('.toc-level-0 > a')[2]).hasText('Classes');
26+
assert.dom('.toc-level-1 li').exists({ count: 2 }, 'We have two items to display');
27+
assert.dom(findAll('.toc-level-1 li')[0]).hasText('Descriptor');
28+
assert.dom(findAll('.toc-level-1 li')[1]).hasText('Ember');
2929
});

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6959,6 +6959,13 @@ quick-temp@^0.1.0, quick-temp@^0.1.2, quick-temp@^0.1.3, quick-temp@^0.1.5, quic
69596959
rimraf "^2.5.4"
69606960
underscore.string "~3.3.4"
69616961

6962+
qunit-dom@^0.3.2:
6963+
version "0.3.2"
6964+
resolved "https://registry.yarnpkg.com/qunit-dom/-/qunit-dom-0.3.2.tgz#175e70d5f2c084c9c0ab26a2869ed9ab2f9ab936"
6965+
dependencies:
6966+
broccoli-funnel "^2.0.0"
6967+
broccoli-merge-trees "^2.0.0"
6968+
69626969
qunit-notifications@^0.1.1:
69636970
version "0.1.1"
69646971
resolved "https://registry.yarnpkg.com/qunit-notifications/-/qunit-notifications-0.1.1.tgz#3001afc6a6a77dfbd962ccbcddde12dec5286c09"

0 commit comments

Comments
 (0)