Skip to content

Commit

Permalink
Merge pull request #94 from Turbo87/test
Browse files Browse the repository at this point in the history
Update tests to "new" testing APIs
  • Loading branch information
Turbo87 committed Apr 28, 2019
2 parents f27820a + 088764a commit 688c9a5
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 110 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
"ember-cli-htmlbars": "^3.0.1",
"ember-cli-htmlbars-inline-precompile": "^2.1.0",
"ember-cli-inject-live-reload": "^2.0.1",
"ember-cli-mocha": "^0.15.0",
"ember-cli-shims": "^1.0.2",
"ember-disable-prototype-extensions": "^1.1.0",
"ember-load-initializers": "^2.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-mocha": "^0.14.0",
"ember-resolver": "^5.0.1",
"ember-source": "~3.9.0",
"ember-try": "^1.1.0",
Expand Down
3 changes: 3 additions & 0 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: 'simplabs/configs/ember-qunit',
parserOptions: {
ecmaVersion: 2017
},
};
Empty file.
1 change: 1 addition & 0 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = function(environment) {
ENV.APP.LOG_VIEW_LOOKUPS = false;

ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
}

if (environment === 'production') {
Expand Down
5 changes: 0 additions & 5 deletions tests/helpers/destroy-app.js

This file was deleted.

21 changes: 0 additions & 21 deletions tests/helpers/module-for-acceptance.js

This file was deleted.

11 changes: 0 additions & 11 deletions tests/helpers/resolver.js

This file was deleted.

16 changes: 0 additions & 16 deletions tests/helpers/start-app.js

This file was deleted.

Empty file removed tests/integration/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { setupComponentTest } from 'ember-mocha';
import { setupRenderingTest } from 'ember-mocha';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

describe('HBS Minifier plugin', function() {
setupComponentTest('dummy-component', { integration: true });
setupRenderingTest();

beforeEach(function() {
this.setProperties({ foo: 'foo', bar: 'bar', baz: 'baz' });
});

it('collapses whitespace into single space character', function() {
this.render(hbs`{{foo}} \n\n \n{{bar}}`);
it('collapses whitespace into single space character', async function() {
await render(hbs`{{foo}} \n\n \n{{bar}}`);

let childNodes = [...this.$()[0].childNodes].filter(it => it.textContent !== '');
expect(childNodes.length).to.equal(3);
expect(childNodes[1]).to.be.a('text');
expect(childNodes[1]).to.have.a.property('textContent', ' ');
});

it('strips leading and trailing whitespace from Program nodes', function() {
this.render(hbs` {{foo}} `);
it('strips leading and trailing whitespace from Program nodes', async function() {
await render(hbs` {{foo}} `);

let childNodes = [...this.$()[0].childNodes].filter(it => it.textContent !== '');
expect(childNodes.length).to.equal(1);
expect(childNodes[0]).to.be.a('text');
expect(childNodes[0]).to.have.a.property('textContent', 'foo');
});

it('Collapse leading/trailing text from Program nodes into a single whitespace', function() {
this.render(hbs`x {{foo}} y `);
it('Collapse leading/trailing text from Program nodes into a single whitespace', async function() {
await render(hbs`x {{foo}} y `);

let childNodes = [...this.$()[0].childNodes].filter(it => it.textContent !== '');
expect(childNodes.length).to.equal(3);
Expand All @@ -41,17 +42,17 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[2]).to.have.a.property('textContent', ' y ');
});

it('strips leading and trailing whitespace from ElementNode nodes', function() {
this.render(hbs`<div> {{foo}} </div>`);
it('strips leading and trailing whitespace from ElementNode nodes', async function() {
await render(hbs`<div> {{foo}} </div>`);

let childNodes = this.$('div')[0].childNodes;
expect(childNodes.length).to.equal(1);
expect(childNodes[0]).to.be.a('text');
expect(childNodes[0]).to.have.a.property('textContent', 'foo');
});

it('Collapse leading/trailing text from ElementNode nodes', function() {
this.render(hbs`<div>x {{foo}} y {{bar}} z</div>`);
it('Collapse leading/trailing text from ElementNode nodes', async function() {
await render(hbs`<div>x {{foo}} y {{bar}} z</div>`);

let childNodes = this.$('div')[0].childNodes;
expect(childNodes.length).to.equal(5);
Expand All @@ -65,8 +66,8 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[4]).to.have.a.property('textContent', ' z');
});

it('does not strip inside of <pre> tags', function() {
this.render(hbs`<pre> {{foo}} </pre>`);
it('does not strip inside of <pre> tags', async function() {
await render(hbs`<pre> {{foo}} </pre>`);

let childNodes = this.$('pre')[0].childNodes;
expect(childNodes.length).to.equal(3);
Expand All @@ -78,17 +79,17 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[2]).to.have.a.property('textContent', ' ');
});

it('does not collapse whitespace inside of <pre> tags', function() {
this.render(hbs`<pre> \n\n \n</pre>`);
it('does not collapse whitespace inside of <pre> tags', async function() {
await render(hbs`<pre> \n\n \n</pre>`);

let childNodes = this.$('pre')[0].childNodes;
expect(childNodes.length).to.equal(1);
expect(childNodes[0]).to.be.a('text');
expect(childNodes[0]).to.have.a.property('textContent', ' \n\n \n');
});

it('does not strip inside of {{#no-minify}} tags', function() {
this.render(hbs`{{#no-minify}} {{foo}} {{/no-minify}}`);
it('does not strip inside of {{#no-minify}} tags', async function() {
await render(hbs`{{#no-minify}} {{foo}} {{/no-minify}}`);

let childNodes = [...this.$()[0].childNodes].filter(it => it.textContent !== '');
expect(childNodes.length).to.equal(3);
Expand All @@ -100,8 +101,8 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[2]).to.have.a.property('textContent', ' ');
});

it('does not strip inside of {{#no-minify}} tags in other tags', function() {
this.render(hbs`<div>{{#no-minify}} {{foo}} {{/no-minify}}</div>`);
it('does not strip inside of {{#no-minify}} tags in other tags', async function() {
await render(hbs`<div>{{#no-minify}} {{foo}} {{/no-minify}}</div>`);

let childNodes = this.$('div')[0].childNodes;
expect(childNodes.length).to.equal(3);
Expand All @@ -113,17 +114,17 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[2]).to.have.a.property('textContent', ' ');
});

it('does not collapse whitespace inside of {{#no-minify}} tags in other tags', function() {
this.render(hbs`<div>{{#no-minify}} \n\n \n{{/no-minify}}</div>`);
it('does not collapse whitespace inside of {{#no-minify}} tags in other tags', async function() {
await render(hbs`<div>{{#no-minify}} \n\n \n{{/no-minify}}</div>`);

let childNodes = this.$('div')[0].childNodes;
expect(childNodes.length).to.equal(1);
expect(childNodes[0]).to.be.a('text');
expect(childNodes[0]).to.have.a.property('textContent', ' \n\n \n');
});

it('does not collapse multiple &nbsp; textNode into a single whitespace', function() {
this.render(hbs`<span>1</span>&nbsp;&nbsp;<span>2</span>`);
it('does not collapse multiple &nbsp; textNode into a single whitespace', async function() {
await render(hbs`<span>1</span>&nbsp;&nbsp;<span>2</span>`);
let childNodes = [...this.$()[0].childNodes].filter(it => it.textContent !== '');
expect(childNodes.length).to.equal(3);
expect(childNodes[1]).to.be.a('text');
Expand All @@ -136,8 +137,8 @@ describe('HBS Minifier plugin', function() {
The following test is so much similar to the above one. But we need to make sure that the textNode in following templates results in
' 1 ' and not ' 1 '.
*/
it('does not collapse &nbsp; surrounding a text content into a single whitespace', function() {
this.render(hbs `
it('does not collapse &nbsp; surrounding a text content into a single whitespace', async function() {
await render(hbs `
<div>
<span> &nbsp;1&nbsp; </span>
<span> 2 </span>
Expand All @@ -149,8 +150,8 @@ describe('HBS Minifier plugin', function() {
expect(childNode.textContent.trim()).to.equal('1');
});

it('does not minify `tagNames` specified in .hbs-minifyrc.js', function() {
this.render(hbs `
it('does not minify `tagNames` specified in .hbs-minifyrc.js', async function() {
await render(hbs `
<address>
Box 564,
<b>
Expand All @@ -170,8 +171,8 @@ describe('HBS Minifier plugin', function() {
});


it('does not minify `classNames` specified in .hbs-minifyrc.js', function() {
this.render(hbs `
it('does not minify `classNames` specified in .hbs-minifyrc.js', async function() {
await render(hbs `
<div class="description">
1
<span>
Expand All @@ -185,8 +186,8 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[2].textContent).to.equal('\n');
});

it('does not minify `component` boundaries specified in .hbs-minifyrc.js', function() {
this.render(hbs `
it('does not minify `component` boundaries specified in .hbs-minifyrc.js', async function() {
await render(hbs `
{{#foo-bar}}
<span>
yield content
Expand All @@ -203,8 +204,8 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[7].textContent).to.equal('\n');
});

it('minify `tagNames` that are not specified in .hbs-minifyrc.js', function() {
this.render(hbs `
it('minify `tagNames` that are not specified in .hbs-minifyrc.js', async function() {
await render(hbs `
<ul>
<li>
1
Expand All @@ -221,8 +222,8 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[2].textContent).to.equal(' 2 ');
});

it('minifies `classNames` that are not specified in .hbs-minifyrc.js', function() {
this.render(hbs `
it('minifies `classNames` that are not specified in .hbs-minifyrc.js', async function() {
await render(hbs `
<div class="numbers">
1
<span>
Expand All @@ -236,8 +237,8 @@ describe('HBS Minifier plugin', function() {
expect(childNodes[1].textContent).to.equal(' 2 ');
});

it('minify `component` boundaries that are not specified in .hbs-minifyrc.js', function() {
this.render(hbs `
it('minify `component` boundaries that are not specified in .hbs-minifyrc.js', async function() {
await render(hbs `
{{#x-button tagName="button"}}
<div>
yield content
Expand Down
7 changes: 4 additions & 3 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import resolver from './helpers/resolver';
import { setResolver } from 'ember-mocha';
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';

setResolver(resolver);
setApplication(Application.create(config.APP));
Empty file removed tests/unit/.gitkeep
Empty file.
50 changes: 35 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,14 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@ember/test-helpers@^0.7.16":
version "0.7.16"
resolved "https://registry.yarnpkg.com/@ember/test-helpers/-/test-helpers-0.7.16.tgz#73a4acf4c7d1b92ce866f4c9e40c9723da4cf1e8"
"@ember/test-helpers@^0.7.18":
version "0.7.27"
resolved "https://registry.yarnpkg.com/@ember/test-helpers/-/test-helpers-0.7.27.tgz#c622cabd0cbb95b34efc1e1b6274ab5a14edc138"
integrity sha512-AQESk0FTFxRY6GyZ8PharR4SC7Fju0rXqNkfNYIntAjzefZ8xEqEM4iXDj5h7gAvfx/8dA69AQ9+p7ubc+KvJg==
dependencies:
broccoli-funnel "^2.0.1"
ember-cli-babel "^6.10.0"
ember-assign-polyfill "~2.4.0"
ember-cli-babel "^6.12.0"
ember-cli-htmlbars-inline-precompile "^1.0.0"

"@glimmer/di@^0.2.0":
Expand Down Expand Up @@ -3186,11 +3188,19 @@ electron-to-chromium@^1.3.86:
version "1.3.88"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.88.tgz#f36ab32634f49ef2b0fdc1e82e2d1cc17feb29e7"

ember-assign-polyfill@~2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/ember-assign-polyfill/-/ember-assign-polyfill-2.4.0.tgz#acb00466f7d674b3e6b030acfe255b3b1f6472e1"
integrity sha512-0SnGQb9CenRqbZdIa1KFsEjT+1ijGWfAbCSaDbg5uVa5l6HPdppuTzOXK6sfEQMsd2nbrp27QWFy7W5VX6l4Ag==
dependencies:
ember-cli-babel "^6.6.0"
ember-cli-version-checker "^2.0.0"

ember-cli-babel-plugin-helpers@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ember-cli-babel-plugin-helpers/-/ember-cli-babel-plugin-helpers-1.1.0.tgz#de3baedd093163b6c2461f95964888c1676325ac"

ember-cli-babel@^6.10.0, ember-cli-babel@^6.11.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.1:
ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.11.0, ember-cli-babel@^6.12.0, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.1:
version "6.18.0"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz#3f6435fd275172edeff2b634ee7b29ce74318957"
dependencies:
Expand Down Expand Up @@ -3326,12 +3336,6 @@ ember-cli-lodash-subset@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/ember-cli-lodash-subset/-/ember-cli-lodash-subset-2.0.1.tgz#20cb68a790fe0fde2488ddfd8efbb7df6fe766f2"

ember-cli-mocha@^0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/ember-cli-mocha/-/ember-cli-mocha-0.15.0.tgz#483b25a2c631b2b1913344686f497a81ced669b6"
dependencies:
ember-mocha "^0.13.0"

ember-cli-normalize-entity-name@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ember-cli-normalize-entity-name/-/ember-cli-normalize-entity-name-1.0.0.tgz#0b14f7bcbc599aa117b5fddc81e4fd03c4bad5b7"
Expand Down Expand Up @@ -3495,11 +3499,22 @@ ember-load-initializers@^2.0.0:
dependencies:
ember-cli-babel "^7.0.0"

ember-mocha@^0.13.0:
version "0.13.1"
resolved "https://registry.yarnpkg.com/ember-mocha/-/ember-mocha-0.13.1.tgz#6c42d76fc7e5579a1ca8499621317b6cde7b4381"
ember-maybe-import-regenerator@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/ember-maybe-import-regenerator/-/ember-maybe-import-regenerator-0.1.6.tgz#35d41828afa6d6a59bc0da3ce47f34c573d776ca"
integrity sha1-NdQYKK+m1qWbwNo85H80xXPXdso=
dependencies:
broccoli-funnel "^1.0.1"
broccoli-merge-trees "^1.0.0"
ember-cli-babel "^6.0.0-beta.4"
regenerator-runtime "^0.9.5"

ember-mocha@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/ember-mocha/-/ember-mocha-0.14.0.tgz#5c14cc1fa7545fe262461856c4ffaf9a662db721"
integrity sha1-XBTMH6dUX+JiRhhWxP+vmmYttyE=
dependencies:
"@ember/test-helpers" "^0.7.16"
"@ember/test-helpers" "^0.7.18"
broccoli-funnel "^2.0.1"
broccoli-merge-trees "^2.0.0"
common-tags "^1.5.1"
Expand Down Expand Up @@ -7455,6 +7470,11 @@ regenerator-runtime@^0.12.0:
version "0.12.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"

regenerator-runtime@^0.9.5:
version "0.9.6"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.9.6.tgz#d33eb95d0d2001a4be39659707c51b0cb71ce029"
integrity sha1-0z65XQ0gAaS+OWWXB8UbDLcc4Ck=

regenerator-transform@^0.10.0:
version "0.10.1"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd"
Expand Down

0 comments on commit 688c9a5

Please sign in to comment.