Fixing visibility tests
MODIFY
package.json
package.json
"ember-maybe-import-regenerator": "^0.1.6",
"ember-resolver": "^4.0.0",
"ember-source": "~2.15.0",
- "loader.js": "^4.2.3"
+ "loader.js": "^4.2.3",
+ "qunit-dom": "^0.5.0"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"

MODIFY
tests/acceptance/deferred-render-test.js
tests/acceptance/deferred-render-test.js
-import { module, test } from 'qunit';
+import QUnit, { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
-import { visit } from '@ember/test-helpers';
+import { visit, find } from '@ember/test-helpers';
+
+QUnit.extend(QUnit.assert, {
+ isVisible: function(el, message) {
+ let result = el !== null && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
+ this.pushResult({ result, actual: result, expected: true, message });
+ },
+ isNotVisible: function(el, message) {
+ let result = el === null || !(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
+ this.pushResult({ result, actual: result, expected: true, message });
+ }
+});
module('Acceptance | deferred render', function(hooks) {
setupApplicationTest(hooks);
@@ -17,14 +28,14 @@ module('Acceptance | deferred render', function(hooks) {
this.router.on('didTransition', () => {
this.scheduler.queues['afterFirstRoutePaint'].afterPaintPromise.then(() => {
const deferredElement = find('.deferred-container ul');
- assert.ok(deferredElement.is(':visible'), 'Deferred content should be visible.');
+ assert.isVisible(deferredElement, 'Deferred content should be visible.');
const adElement = find('.ad-container h3');
- assert.notOk(adElement.is(':visible'), 'Ad should not be visible.');
+ assert.isNotVisible(adElement, 'Ad should not be visible.');
});
this.scheduler.queues['afterContentPaint'].afterPaintPromise.then(() => {
const adElement = find('.ad-container h3');
- assert.ok(adElement.is(':visible'), 'Ad should be visible.');
+ assert.isVisible(adElement, 'Ad should be visible.');
done();
});
});
@@ -40,14 +51,14 @@ module('Acceptance | deferred render', function(hooks) {
this.router.on('didTransition', () => {
this.scheduler.queues['afterFirstRoutePaint'].afterPaintPromise.then(() => {
const deferredElement = find('.deferred-container ul');
- assert.ok(deferredElement.is(':visible'), 'Deferred content should be visible.');
+ assert.isVisible(deferredElement, 'Deferred content should be visible.');
const adElement = find('.ad-container h3');
- assert.notOk(adElement.is(':visible'), 'Ad should not be visible.');
+ assert.isNotVisible(adElement, 'Ad should not be visible.');
});
this.scheduler.queues['afterContentPaint'].afterPaintPromise.then(() => {
const adElement = find('.ad-container h3');
- assert.ok(adElement.is(':visible'), 'Ad should be visible.');
+ assert.isVisible(adElement, 'Ad should be visible.');
this.scheduler._useRAF = true;
done();
});

MODIFY
yarn.lock
yarn.lock
@@ -1172,7 +1172,7 @@ broccoli-funnel@^1.0.0, broccoli-funnel@^1.0.1, broccoli-funnel@^1.0.6, broccoli
symlink-or-copy "^1.0.0"
walk-sync "^0.3.1"
-broccoli-funnel@^2.0.1:
+broccoli-funnel@^2.0.0, broccoli-funnel@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-2.0.1.tgz#6823c73b675ef78fffa7ab800f083e768b51d449"
dependencies:
@@ -4616,6 +4616,13 @@ quick-temp@^0.1.8:
rimraf "^2.5.4"
underscore.string "~3.3.4"
+qunit-dom@^0.5.0:
+ version "0.5.0"
+ resolved "https://registry.yarnpkg.com/qunit-dom/-/qunit-dom-0.5.0.tgz#b08db6f919656e0589ebf8bd85bc313febb454d8"
+ dependencies:
+ broccoli-funnel "^2.0.0"
+ broccoli-merge-trees "^2.0.0"
+
qunit@^2.5.0:
version "2.5.1"
resolved "https://registry.yarnpkg.com/qunit/-/qunit-2.5.1.tgz#739b0ea9595bbf508b0600d5af04dcb2ba2a74e5"

Fixing visibility tests