Skip to content

Commit

Permalink
Merge pull request #139 from ember-engines/eslint-plugin-qunit
Browse files Browse the repository at this point in the history
Introduce `eslint-plugin-qunit` per latest addon blueprint
  • Loading branch information
SergeAstapov authored May 28, 2022
2 parents 4be0cb2 + cd836ca commit a1ad98c
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@ module.exports = {
],
},
},
{
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"eslint-plugin-ember": "^10.6.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-qunit": "^7.2.0",
"loader.js": "^4.7.0",
"mocha": "^6.0.2",
"npm-run-all": "^4.1.5",
Expand Down
14 changes: 9 additions & 5 deletions tests/acceptance/asset-load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,25 @@ module('Acceptance | asset-load', function (hooks) {
const originalColor = originalContainerStyle.color;

let containerText = container.innerText;
assert.equal(containerText, '', 'test container is empty before load');
assert.strictEqual(
containerText,
'',
'test container is empty before load'
);

await visit('/');

assert.equal(currentRouteName(), 'index', 'transitioned ');
assert.strictEqual(currentRouteName(), 'index', 'transitioned ');

const testScriptText = container.querySelector('h2').innerText;
assert.equal(
assert.strictEqual(
testScriptText,
'Test script loaded!',
'test script was executed'
);

const routeText = container.querySelector('h1').innerText;
assert.equal(routeText, 'Welcome!', 'route was loaded correctly');
assert.strictEqual(routeText, 'Welcome!', 'route was loaded correctly');

containerText = container.innerText;
assert.ok(
Expand Down Expand Up @@ -88,7 +92,7 @@ module('Acceptance | asset-load', function (hooks) {

await visit('asset-error');

assert.equal(currentRouteName(), 'asset-error', 'transitioned ');
assert.strictEqual(currentRouteName(), 'asset-error', 'transitioned ');

return waitFor(() => !getScript())
.catch((reason) => {
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/asset-manifest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ module('Unit | asset-manifest', function (hooks) {
});

test('throws an error if unable to load the manifest', function (assert) {
assert.expect(1);

delete requirejs.entries['dummy/config/node-asset-manifest'];

const meta = document.querySelector(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/errors/asset-load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module('Unit | Error | asset-load', function (hooks) {
this.asset,
this.originalError
);
assert.equal(
assert.strictEqual(
error.toString(),
'AssetLoadError: The js asset with uri "some-js-file.js" failed to load with the error: Error: some error.'
);
Expand All @@ -46,7 +46,7 @@ module('Unit | Error | asset-load', function (hooks) {
this.asset,
this.originalError
);
assert.equal(
assert.strictEqual(
error.retryLoad(),
'Loaded js asset with uri "some-js-file.js".'
);
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/errors/bundle-load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module('Unit | Error | bundle-load', function (hooks) {
);
assert.ok(error instanceof Error, 'BundleLoadError inherits Error');
assert.ok(error.stack, 'stack is preserved');
assert.equal(error.bundleName, this.bundleName, 'bundleName is set');
assert.strictEqual(error.bundleName, this.bundleName, 'bundleName is set');
assert.strictEqual(error.errors, this.errors, 'errors is set');
});

Expand All @@ -32,7 +32,7 @@ module('Unit | Error | bundle-load', function (hooks) {
this.bundleName,
this.errors
);
assert.equal(
assert.strictEqual(
error.toString(),
'BundleLoadError: The bundle "herp-de-derp" failed to load.'
);
Expand All @@ -44,6 +44,6 @@ module('Unit | Error | bundle-load', function (hooks) {
this.bundleName,
this.errors
);
assert.equal(error.retryLoad(), 'Loaded the bundle "herp-de-derp".');
assert.strictEqual(error.retryLoad(), 'Loaded the bundle "herp-de-derp".');
});
});
4 changes: 2 additions & 2 deletions tests/unit/errors/load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module('Unit | Error | load', function () {

assert.ok(error instanceof Error, 'LoadError inherits Error');
assert.ok(error.stack, 'stack is preserved');
assert.equal(error.message, message, 'message is set');
assert.strictEqual(error.message, message, 'message is set');
assert.strictEqual(error.loader, loader, 'loader is set');
});

test('toString() - has correct name and message', function (assert) {
const error = new LoadError('herp-de-derp');
assert.equal(error.toString(), 'LoadError: herp-de-derp');
assert.strictEqual(error.toString(), 'LoadError: herp-de-derp');
});

test('retryLoad() - throws an error', function (assert) {
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/services/asset-loader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module('Unit | Service | asset-loader', function (hooks) {
});

return service.loadBundle('blog').then((bundle) => {
assert.equal(bundle, 'blog');
assert.strictEqual(bundle, 'blog');
});
});

Expand Down Expand Up @@ -97,12 +97,12 @@ module('Unit | Service | asset-loader', function (hooks) {
service.defineLoader('fail', () => RSVP.reject('rejected'));

return service.loadBundle('blog').then(shouldNotHappen(assert), (error) => {
assert.equal(
assert.strictEqual(
error.errors.length,
1,
'has an array of the errors causing the load to fail.'
);
assert.equal(
assert.strictEqual(
error.toString(),
'BundleLoadError: The bundle "blog" failed to load.',
'error message contains correct info.'
Expand Down Expand Up @@ -258,7 +258,7 @@ module('Unit | Service | asset-loader', function (hooks) {
service.defineLoader('test', () => RSVP.reject('some error'));

return service.loadAsset(asset).then(shouldNotHappen(assert), (error) => {
assert.equal(
assert.strictEqual(
error.toString(),
'AssetLoadError: The test asset with uri "someuri" failed to load with the error: some error.'
);
Expand Down Expand Up @@ -383,7 +383,7 @@ module('Unit | Service | asset-loader', function (hooks) {

return service.loadAsset(asset).then(() => {
const newNumScripts = document.querySelectorAll('script').length;
assert.equal(newNumScripts, numScripts);
assert.strictEqual(newNumScripts, numScripts);
});
});

Expand All @@ -395,7 +395,7 @@ module('Unit | Service | asset-loader', function (hooks) {

return service.loadAsset(asset).then(() => {
const script = document.querySelector('script[src="/unit-test.js"]');
assert.equal(script.async, false);
assert.false(script.async);
});
});

Expand Down Expand Up @@ -445,7 +445,7 @@ module('Unit | Service | asset-loader', function (hooks) {

return service.loadAsset(asset).then(() => {
const newNumLinks = document.querySelectorAll('link').length;
assert.equal(newNumLinks, numLinks);
assert.strictEqual(newNumLinks, numLinks);
});
});

Expand Down
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7592,6 +7592,14 @@ eslint-plugin-prettier@^4.0.0:
dependencies:
prettier-linter-helpers "^1.0.0"

eslint-plugin-qunit@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-qunit/-/eslint-plugin-qunit-7.2.0.tgz#ad00e0007dc0bbd1d59309cc6388238b6a8784a3"
integrity sha512-ebT6aOpmMj4vchG0hVw9Ukbutk/lgywrc8gc9w9hH2/4WjKqwMlyM7iVwqB7OAXv6gtQMJZuziT0wNjjymAuWA==
dependencies:
eslint-utils "^3.0.0"
requireindex "^1.2.0"

[email protected], eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down Expand Up @@ -13791,6 +13799,7 @@ terser@^5.7.2:

"test-generator-plugin@link:./tests/dummy/lib/test-generator-plugin":
version "0.0.0"
uid ""

testem@^2.14.0:
version "2.17.0"
Expand Down

0 comments on commit a1ad98c

Please sign in to comment.