diff --git a/package.json b/package.json index 44a0375b5..c490ca8c3 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,8 @@ "fastboot-app-server": "^1.0.1", "loader.js": "^4.6.0", "minimist": "^1.2.0", - "normalize.css": "^7.0.0" + "normalize.css": "^7.0.0", + "qunit-dom": "^0.3.2" }, "engines": { "node": "8", diff --git a/tests/acceptance/app-layout-test.js b/tests/acceptance/app-layout-test.js index 1b75f4144..201aa7b05 100644 --- a/tests/acceptance/app-layout-test.js +++ b/tests/acceptance/app-layout-test.js @@ -9,6 +9,6 @@ test('lists the project versions in a select box', async function(assert) { await selectSearch('.select-container', '2'); - assert.equal(find('.ember-power-select-options').length, 1); + assert.dom('.ember-power-select-options').exists({ count: 1 }); assert.ok(find('.ember-power-select-options')[0].children.length > 1); }); diff --git a/tests/acceptance/method-inheritance-test.js b/tests/acceptance/method-inheritance-test.js index 4d531d7f7..643697f92 100644 --- a/tests/acceptance/method-inheritance-test.js +++ b/tests/acceptance/method-inheritance-test.js @@ -1,13 +1,13 @@ import moduleForAcceptance from 'ember-api-docs/tests/helpers/module-for-acceptance'; import {skip} from 'qunit'; -import { visit, click, findAll, findWithAssert } from 'ember-native-dom-helpers'; +import { visit, click, findWithAssert } from 'ember-native-dom-helpers'; import testSelector from 'ember-test-selectors'; moduleForAcceptance('Acceptance | method inheritance') skip('no duplicate methods displayed', async function (assert) { await visit('/ember-data/2.14/classes/DS.JSONAPIAdapter'); - assert.equal(findAll("[data-test-item='createRecord']").length, 1); + assert.dom("[data-test-item='createRecord']").exists({ count: 1 }); }); skip('most local inherited method is shown', async function (assert) { diff --git a/tests/acceptance/switch-project-test.js b/tests/acceptance/switch-project-test.js index be16a50e4..8d94e945a 100644 --- a/tests/acceptance/switch-project-test.js +++ b/tests/acceptance/switch-project-test.js @@ -14,7 +14,7 @@ skip('Can switch projects back and forth', async function(assert) { async function ensureVersionsExist() { await selectSearch('.select-container', '2'); - assert.equal(findAll('.ember-power-select-options').length, 1); + assert.dom('.ember-power-select-options').exists({ count: 1 }); assert.ok(findAll('.ember-power-select-options')[0].children.length > 1); } diff --git a/tests/integration/components/api-index-filter-test.js b/tests/integration/components/api-index-filter-test.js index 20017760c..9316cce66 100644 --- a/tests/integration/components/api-index-filter-test.js +++ b/tests/integration/components/api-index-filter-test.js @@ -110,9 +110,9 @@ test('clicking inherited shows inherited methods', async function(assert) { `); await click('#inherited-toggle'); - assert.equal(findAll('.method-name').length, 2, 'should display 2 methods total'); - assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); - assert.equal(findAll('.method-name')[1].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method'); + assert.dom('.method-name').exists({ count: 2 }, 'should display 2 methods total'); + assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method'); + assert.dom(findAll('.method-name')[1]).hasText('parentDoSomething', 'should display 1 inherited method'); }); test('clicking private shows private methods', async function(assert) { @@ -169,9 +169,9 @@ test('clicking private shows private methods', async function(assert) { `); await click('#private-toggle'); - assert.equal(findAll('.method-name').length, 2, 'should display 2 methods total'); - assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); - assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method'); + assert.dom('.method-name').exists({ count: 2 }, 'should display 2 methods total'); + assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method'); + assert.dom(findAll('.method-name')[1]).hasText('doSomethingPrivate', 'should display 1 private method'); }); 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) await click('#private-toggle'); await click('#inherited-toggle'); - assert.equal(findAll('.method-name').length, 3, 'should display 3 methods total'); - assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); - assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method'); - assert.equal(findAll('.method-name')[2].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method'); + assert.dom('.method-name').exists({ count: 3 }, 'should display 3 methods total'); + assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method'); + assert.dom(findAll('.method-name')[1]).hasText('doSomethingPrivate', 'should display 1 private method'); + assert.dom(findAll('.method-name')[2]).hasText('parentDoSomething', 'should display 1 inherited method'); }); @@ -293,12 +293,12 @@ test('clicking all toggles shows all methods', async function(assert) { await click('#inherited-toggle'); await click('#protected-toggle'); await click('#deprecated-toggle'); - assert.equal(findAll('.method-name').length, 5, 'should display all methods'); - assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); - assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingDeprecated', 'should display 1 deprecated method'); - assert.equal(findAll('.method-name')[2].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method'); - assert.equal(findAll('.method-name')[3].textContent.trim(), 'doSomethingProtected', 'should display 1 protected method'); - assert.equal(findAll('.method-name')[4].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method'); + assert.dom('.method-name').exists({ count: 5 }, 'should display all methods'); + assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method'); + assert.dom(findAll('.method-name')[1]).hasText('doSomethingDeprecated', 'should display 1 deprecated method'); + assert.dom(findAll('.method-name')[2]).hasText('doSomethingPrivate', 'should display 1 private method'); + assert.dom(findAll('.method-name')[3]).hasText('doSomethingProtected', 'should display 1 protected method'); + assert.dom(findAll('.method-name')[4]).hasText('parentDoSomething', 'should display 1 inherited method'); }); @@ -355,19 +355,19 @@ test('clicking all toggles off should only show public', async function(assert) {{/api-index-filter}} `); - assert.equal(findAll('.method-name').length, 5, 'should display all methods'); - assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); - assert.equal(findAll('.method-name')[1].textContent.trim(), 'doSomethingDeprecated', 'should display 1 deprecated method'); - assert.equal(findAll('.method-name')[2].textContent.trim(), 'doSomethingPrivate', 'should display 1 private method'); - assert.equal(findAll('.method-name')[3].textContent.trim(), 'doSomethingProtected', 'should display 1 protected method'); - assert.equal(findAll('.method-name')[4].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method'); + assert.dom('.method-name').exists({ count: 5 }, 'should display all methods'); + assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method'); + assert.dom(findAll('.method-name')[1]).hasText('doSomethingDeprecated', 'should display 1 deprecated method'); + assert.dom(findAll('.method-name')[2]).hasText('doSomethingPrivate', 'should display 1 private method'); + assert.dom(findAll('.method-name')[3]).hasText('doSomethingProtected', 'should display 1 protected method'); + assert.dom(findAll('.method-name')[4]).hasText('parentDoSomething', 'should display 1 inherited method'); await click('#private-toggle'); await click('#inherited-toggle'); await click('#protected-toggle'); await click('#deprecated-toggle'); - assert.equal(findAll('.method-name').length, 1, 'should display all methods'); - assert.equal(findAll('.method-name')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); + assert.dom('.method-name').exists({ count: 1 }, 'should display all methods'); + assert.dom(findAll('.method-name')[0]).hasText('doSomething', 'should display 1 public method'); }); diff --git a/tests/integration/components/api-index-test.js b/tests/integration/components/api-index-test.js index edbabc82d..bf8cac1ac 100644 --- a/tests/integration/components/api-index-test.js +++ b/tests/integration/components/api-index-test.js @@ -1,7 +1,7 @@ import EmberObject from '@ember/object'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import { click, findAll, find } from 'ember-native-dom-helpers'; +import { click, findAll } from 'ember-native-dom-helpers'; moduleForComponent('api-index', 'Integration | Component | api index', { integration: true @@ -63,13 +63,13 @@ test('should display api index', function (assert) { {{/each}} {{/api-index}} `); - assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections'); - assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section'); - assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section'); - assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section'); - assert.equal(find('.spec-method-list>li>a').textContent.trim(), 'doSomething', 'should display 1 method'); - assert.equal(find('.spec-property-list>li>a').textContent.trim(), 'isSomething', 'should display 1 property'); - assert.equal(find('.spec-event-list>li>a').textContent.trim(), 'didSomething', 'should display 1 event'); + assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections'); + assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section'); + assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section'); + assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section'); + assert.dom('.spec-method-list>li>a').hasText('doSomething', 'should display 1 method'); + assert.dom('.spec-property-list>li>a').hasText('isSomething', 'should display 1 property'); + assert.dom('.spec-event-list>li>a').hasText('didSomething', 'should display 1 event'); }); test('should display text when no methods', function (assert) { @@ -123,13 +123,13 @@ test('should display text when no methods', function (assert) { {{/each}} {{/api-index}} `); - assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections'); - assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section'); - assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section'); - assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section'); - assert.equal(find('.spec-method-list').textContent.trim(), 'No documented items', 'should display no items text'); - assert.equal(find('.spec-property-list').textContent.trim(), 'isSomething', 'should display 1 property'); - assert.equal(find('.spec-event-list').textContent.trim(), 'didSomething', 'should display 1 event'); + assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections'); + assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section'); + assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section'); + assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section'); + assert.dom('.spec-method-list').hasText('No documented items', 'should display no items text'); + assert.dom('.spec-property-list').hasText('isSomething', 'should display 1 property'); + assert.dom('.spec-event-list').hasText('didSomething', 'should display 1 event'); }); test('should display api index with filter', function (assert) { @@ -253,13 +253,13 @@ test('should display api index with filter', function (assert) { {{/api-index}} {{/api-index-filter}} `); - assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections'); - assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section'); - assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section'); - assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section'); - assert.equal(find('.spec-method-list').textContent.trim(), 'doSomething', 'should display 1 method'); - assert.equal(find('.spec-property-list').textContent.trim(), 'isSomething', 'should display 1 property'); - assert.equal(find('.spec-event-list').textContent.trim(), 'didSomething', 'should display 1 event'); + assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections'); + assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section'); + assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section'); + assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section'); + assert.dom('.spec-method-list').hasText('doSomething', 'should display 1 method'); + assert.dom('.spec-property-list').hasText('isSomething', 'should display 1 property'); + assert.dom('.spec-event-list').hasText('didSomething', 'should display 1 event'); }); @@ -382,17 +382,17 @@ test('should display inherited method when show inherited toggled on', async fun {{/api-index}} {{/api-index-filter}} `); - assert.equal(findAll('.api-index-section-title').length, 3, 'should show 3 sections'); - assert.equal(findAll('.api-index-section-title')[0].textContent, 'Methods', 'should have methods as first section'); - assert.equal(findAll('.api-index-section-title')[1].textContent, 'Properties', 'should have properties as second section'); - assert.equal(findAll('.api-index-section-title')[2].textContent, 'Events', 'should have events as third section'); - assert.equal(find('.spec-method-list>li>a').textContent.trim(), 'doSomething', 'should display 1 method'); - assert.equal(find('.spec-property-list>li>a').textContent.trim(), 'isSomething', 'should display 1 property'); - assert.equal(find('.spec-event-list>li>a').textContent.trim(), 'didSomething', 'should display 1 event'); + assert.dom('.api-index-section-title').exists({ count: 3 }, 'should show 3 sections'); + assert.dom(findAll('.api-index-section-title')[0]).hasText('Methods', 'should have methods as first section'); + assert.dom(findAll('.api-index-section-title')[1]).hasText('Properties', 'should have properties as second section'); + assert.dom(findAll('.api-index-section-title')[2]).hasText('Events', 'should have events as third section'); + assert.dom('.spec-method-list>li>a').hasText('doSomething', 'should display 1 method'); + assert.dom('.spec-property-list>li>a').hasText('isSomething', 'should display 1 property'); + assert.dom('.spec-event-list>li>a').hasText('didSomething', 'should display 1 event'); await click('#inherited-toggle'); - assert.equal(findAll('.spec-method-list>li>a').length, 2, 'should display 2 methods total'); - assert.equal(findAll('.spec-method-list>li>a')[0].textContent.trim(), 'doSomething', 'should display 1 public method'); - assert.equal(findAll('.spec-method-list>li>a')[1].textContent.trim(), 'parentDoSomething', 'should display 1 inherited method'); + assert.dom('.spec-method-list>li>a').exists({ count: 2 }, 'should display 2 methods total'); + assert.dom(findAll('.spec-method-list>li>a')[0]).hasText('doSomething', 'should display 1 public method'); + assert.dom(findAll('.spec-method-list>li>a')[1]).hasText('parentDoSomething', 'should display 1 inherited method'); }); diff --git a/tests/integration/components/class-field-description-test.js b/tests/integration/components/class-field-description-test.js index 106480767..48f7151b8 100644 --- a/tests/integration/components/class-field-description-test.js +++ b/tests/integration/components/class-field-description-test.js @@ -1,7 +1,7 @@ import EmberObject from '@ember/object'; import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; -import { find, findAll, triggerEvent } from 'ember-native-dom-helpers'; +import { findAll, triggerEvent } from 'ember-native-dom-helpers'; moduleForComponent('class-field-description', 'Integration | Component | class field description', { integration: true @@ -19,10 +19,10 @@ test('it renders', function(assert) { this.render(hbs`{{class-field-description type=type field=field}}`); - assert.equal(find('.method-name').textContent.trim(), 'concat'); - assert.equal(findAll('.access')[0].textContent.trim(), 'public'); - assert.equal(findAll('.access')[1].textContent.trim(), 'deprecated'); - assert.equal(findAll('.args')[0].textContent.trim(), '(param1, param2, param3)'); + assert.dom('.method-name').hasText('concat'); + assert.dom(findAll('.access')[0]).hasText('public'); + assert.dom(findAll('.access')[1]).hasText('deprecated'); + assert.dom(findAll('.args')[0]).hasText('(param1, param2, param3)'); }); @@ -39,5 +39,5 @@ test('On hover -- the link icon shows up', async function(assert) { this.render(hbs`{{class-field-description type=type field=field}}`); await triggerEvent('.class-field-description--link', 'mouseenter'); - assert.ok(find('.class-field-description--link-hover'), 'The link icon appears when hovering on the method text'); + assert.dom('.class-field-description--link-hover').exists('The link icon appears when hovering on the method text'); }); diff --git a/tests/integration/components/table-of-contents-test.js b/tests/integration/components/table-of-contents-test.js index faaeeea9e..773c109b5 100644 --- a/tests/integration/components/table-of-contents-test.js +++ b/tests/integration/components/table-of-contents-test.js @@ -22,8 +22,8 @@ skip('it renders', function(assert) { classesIDs=classesIDs }}`); - assert.equal(findAll('.toc-level-0 > a')[2].textContent.trim(), 'Classes'); - assert.equal(findAll('.toc-level-1 li').length, 2, 'We have two items to display'); - assert.equal(findAll('.toc-level-1 li')[0].textContent.trim(), 'Descriptor'); - assert.equal(findAll('.toc-level-1 li')[1].textContent.trim(), 'Ember'); + assert.dom(findAll('.toc-level-0 > a')[2]).hasText('Classes'); + assert.dom('.toc-level-1 li').exists({ count: 2 }, 'We have two items to display'); + assert.dom(findAll('.toc-level-1 li')[0]).hasText('Descriptor'); + assert.dom(findAll('.toc-level-1 li')[1]).hasText('Ember'); }); diff --git a/yarn.lock b/yarn.lock index 505d6744e..f4e99eadf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 rimraf "^2.5.4" underscore.string "~3.3.4" +qunit-dom@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/qunit-dom/-/qunit-dom-0.3.2.tgz#175e70d5f2c084c9c0ab26a2869ed9ab2f9ab936" + dependencies: + broccoli-funnel "^2.0.0" + broccoli-merge-trees "^2.0.0" + qunit-notifications@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/qunit-notifications/-/qunit-notifications-0.1.1.tgz#3001afc6a6a77dfbd962ccbcddde12dec5286c09"