Skip to content

Commit

Permalink
Lints pass now
Browse files Browse the repository at this point in the history
Lints pass now
  • Loading branch information
NullVoxPopuli committed May 4, 2023
1 parent 2ea40dd commit c3c83d0
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 78 deletions.
1 change: 1 addition & 0 deletions test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@ember/optional-features": "^2.0.0",
"@ember/string": "^3.0.1",
"@ember/test-helpers": "^2.9.3",
"@ember/test-waiters": "^3.0.2",
"@embroider/test-setup": "^2.1.1",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
Expand Down
69 changes: 40 additions & 29 deletions test-app/tests/acceptance/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ module('setupApplicationTest tests', function (hooks) {
return;
}

const Router = EmberRouter.extend({ location: 'none' });
class Router extends EmberRouter {
location = 'none';
}
Router.map(function () {
this.route('widgets');
this.route('posts', function () {
Expand All @@ -37,86 +39,95 @@ module('setupApplicationTest tests', function (hooks) {
'template:index': hbs`<h1>Hello World!</h1>`,
'template:posts': hbs`<h1>Posts Page</h1>{{outlet}}`,
'template:posts/post': hbs`<div class="post-id">{{this.model.post_id}}</div>`,
'route:posts/post': Route.extend({
'route:posts/post': class extends Route {
model(params) {
return params;
},
}),
}
},
});
});

test('can render', async function (assert) {
await visit('/');

assert.equal(currentRouteName(), 'index');
assert.equal(currentURL(), '/');
assert.strictEqual(currentRouteName(), 'index');
assert.strictEqual(currentURL(), '/');

assert.equal(
assert.strictEqual(
this.element.querySelector('.nav').textContent,
'posts | widgets'
);
assert.equal(this.element.querySelector('h1').textContent, 'Hello World!');
assert.strictEqual(
this.element.querySelector('h1').textContent,
'Hello World!'
);
});

test('can perform a basic template rendering for nested route', async function (assert) {
await visit('/posts/1');

assert.equal(currentRouteName(), 'posts.post');
assert.equal(currentURL(), '/posts/1');
assert.strictEqual(currentRouteName(), 'posts.post');
assert.strictEqual(currentURL(), '/posts/1');

assert.equal(
assert.strictEqual(
this.element.querySelector('.nav').textContent,
'posts | widgets'
);
assert.equal(this.element.querySelector('.post-id').textContent, '1');
assert.strictEqual(this.element.querySelector('.post-id').textContent, '1');
});

test('can visit multiple times', async function (assert) {
await visit('/posts/1');

assert.equal(currentRouteName(), 'posts.post');
assert.equal(currentURL(), '/posts/1');
assert.strictEqual(currentRouteName(), 'posts.post');
assert.strictEqual(currentURL(), '/posts/1');

assert.equal(
assert.strictEqual(
this.element.querySelector('.nav').textContent,
'posts | widgets'
);
assert.equal(this.element.querySelector('.post-id').textContent, '1');
assert.strictEqual(this.element.querySelector('.post-id').textContent, '1');

await visit('/');

assert.equal(currentRouteName(), 'index');
assert.equal(currentURL(), '/');
assert.strictEqual(currentRouteName(), 'index');
assert.strictEqual(currentURL(), '/');

assert.equal(
assert.strictEqual(
this.element.querySelector('.nav').textContent,
'posts | widgets'
);
assert.equal(this.element.querySelector('h1').textContent, 'Hello World!');
assert.strictEqual(
this.element.querySelector('h1').textContent,
'Hello World!'
);

await visit('/posts/2');

assert.equal(currentRouteName(), 'posts.post');
assert.equal(currentURL(), '/posts/2');
assert.strictEqual(currentRouteName(), 'posts.post');
assert.strictEqual(currentURL(), '/posts/2');

assert.equal(
assert.strictEqual(
this.element.querySelector('.nav').textContent,
'posts | widgets'
);
assert.equal(this.element.querySelector('.post-id').textContent, '2');
assert.strictEqual(this.element.querySelector('.post-id').textContent, '2');
});

test('can navigate amongst routes', async function (assert) {
await visit('/');

assert.equal(currentRouteName(), 'index');
assert.equal(currentURL(), '/');
assert.strictEqual(currentRouteName(), 'index');
assert.strictEqual(currentURL(), '/');

await click('a[href="/posts"]');

assert.equal(currentRouteName(), 'posts.index');
assert.equal(currentURL(), '/posts');
assert.strictEqual(currentRouteName(), 'posts.index');
assert.strictEqual(currentURL(), '/posts');

assert.equal(this.element.querySelector('h1').textContent, 'Posts Page');
assert.strictEqual(
this.element.querySelector('h1').textContent,
'Posts Page'
);
});
});
11 changes: 8 additions & 3 deletions test-app/tests/integration/setup-rendering-test-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable ember/no-classic-components */
import { module, test } from 'qunit';
import Component from '@ember/component';
import { helper } from '@ember/component/helper';
Expand All @@ -16,7 +17,7 @@ module('setupRenderingTest tests', function (hooks) {
test('can render a simple template', async function (assert) {
await render(hbs`<p>Hello!</p>`);

assert.equal(this.element.textContent, 'Hello!');
assert.strictEqual(this.element.textContent, 'Hello!');
});

test('can invoke template only components', async function (assert) {
Expand All @@ -26,12 +27,16 @@ module('setupRenderingTest tests', function (hooks) {
);
await render(hbs`<TemplateOnly />`);

assert.equal(this.element.textContent, 'template-only component here');
assert.strictEqual(
this.element.textContent,
'template-only component here'
);
});

test('can invoke JS only components', async function (assert) {
this.owner.register(
'component:js-only',
// eslint-disable-next-line ember/no-classic-classes
Component.extend({
classNames: ['js-only'],
})
Expand All @@ -53,6 +58,6 @@ module('setupRenderingTest tests', function (hooks) {

await render(hbs`{{jax "max"}}`);

assert.equal(this.element.textContent, 'max-jax');
assert.strictEqual(this.element.textContent, 'max-jax');
});
});
42 changes: 11 additions & 31 deletions test-app/tests/integration/setup-test-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { module, test } from 'qunit';
import Service, { inject as injectService } from '@ember/service';
import Component from '@ember/component';
import { setupTest } from 'ember-qunit';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

Expand All @@ -14,28 +13,29 @@ module('setupTest tests', function (hooks) {
test('can be used for unit style testing', function (assert) {
this.owner.register(
'service:foo',
Service.extend({
class extends Service {
someMethod() {
return 'hello thar!';
},
})
}
}
);

let subject = this.owner.lookup('service:foo');

assert.equal(subject.someMethod(), 'hello thar!');
assert.strictEqual(subject.someMethod(), 'hello thar!');
});

test('can access a shared service instance', function (assert) {
this.owner.register('service:bar', Service.extend());
this.owner.register('service:bar', class extends Service {});
this.owner.register(
'service:foo',
Service.extend({
bar: injectService(),
class extends Service {
@injectService bar;

someMethod() {
this.set('bar.someProp', 'derp');
},
})
}
}
);

let subject = this.owner.lookup('service:foo');
Expand All @@ -45,26 +45,6 @@ module('setupTest tests', function (hooks) {

subject.someMethod();

assert.equal(bar.get('someProp'), 'derp', 'property updated');
});

test('can create a component instance for direct testing without a template', function (assert) {
this.owner.register(
'component:foo-bar',
Component.extend({
someMethod() {
return 'hello thar!';
},
})
);

let subject;
if (hasEmberVersion(2, 12)) {
subject = this.owner.lookup('component:foo-bar');
} else {
subject = this.owner._lookupFactory('component:foo-bar').create();
}

assert.equal(subject.someMethod(), 'hello thar!');
assert.strictEqual(bar.get('someProp'), 'derp', 'property updated');
});
});
7 changes: 6 additions & 1 deletion test-app/tests/unit/adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Promise } from 'rsvp';
module('QUnitAdapter');

test('asyncStart waits for asyncEnd to finish a test', function (assert) {
assert.expect(1);
const adapter = QUnitAdapter.create();

adapter.asyncStart();
Expand All @@ -19,6 +20,7 @@ test('asyncStart waits for asyncEnd to finish a test', function (assert) {
});

test('asyncStart waits for equal numbers of asyncEnd to finish a test', function (assert) {
assert.expect(1);
const adapter = QUnitAdapter.create();

adapter.asyncStart();
Expand All @@ -32,6 +34,7 @@ test('asyncStart waits for equal numbers of asyncEnd to finish a test', function
});

test('asyncStart should handle skipped tests that has no assert', function (assert) {
assert.expect(2);
let FakeQUnitWithoutAssert = {
config: {
current: {},
Expand All @@ -41,7 +44,7 @@ test('asyncStart should handle skipped tests that has no assert', function (asse
const adapter = QUnitAdapter.create({ qunit: FakeQUnitWithoutAssert });

adapter.asyncStart();
assert.equal(adapter.doneCallbacks.length, 1);
assert.strictEqual(adapter.doneCallbacks.length, 1);
assert.deepEqual(adapter.doneCallbacks, [
{
test: FakeQUnitWithoutAssert.config.current,
Expand All @@ -54,6 +57,7 @@ module('QUnitAdapter - Balanced async with native Promise', function () {
const adapter = QUnitAdapter.create();

test('asyncStart invoked', function (assert) {
assert.expect(1);
adapter.asyncStart();

assert.ok(true);
Expand All @@ -74,6 +78,7 @@ module('QUnitAdapter - Balanced async with RSVP.Promise', function () {
const adapter = QUnitAdapter.create();

test('asyncStart invoked', function (assert) {
assert.expect(1);
adapter.asyncStart();

assert.ok(true);
Expand Down
17 changes: 6 additions & 11 deletions test-app/tests/unit/test-isolation-validation-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';
import { later, _backburner as backburner } from '@ember/runloop';
import { module, test } from 'qunit';
import { registerWaiter, unregisterWaiter } from '@ember/test';
import QUnit, { module, test } from 'qunit';
import { installTestNotIsolatedHook } from 'ember-qunit/test-isolation-validation';
import { getDebugInfo } from '@ember/test-helpers';
import patchAssert from './utils/patch-assert-helper';
Expand All @@ -14,17 +14,12 @@ if (getDebugInfo()) {
return !isWaiterPending;
};

// In Ember < 2.8 `registerWaiter` expected to be bound to
// `Ember.Test` 😭
//
// Once we have dropped support for < 2.8 we should swap this to
// use:
//
// import { registerWaiter } from '@ember/test';
Ember.Test.registerWaiter(waiter);
// eslint-disable-next-line ember/no-legacy-test-waiters
registerWaiter(waiter);

QUnit.on('testEnd', function () {
Ember.Test.unregisterWaiter(this._waiter);
// eslint-disable-next-line ember/no-legacy-test-waiters
unregisterWaiter(this._waiter);
});

hooks.beforeEach(function () {
Expand Down
6 changes: 4 additions & 2 deletions test-app/tests/unit/unhandled-rejection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module('unhandle promise rejections', function (hooks) {
});

test('RSVP promises cause an unhandled rejection', function (assert) {
assert.expect(2);
let done = assert.async();

window.onerror = (message) => {
Expand All @@ -36,7 +37,7 @@ module('unhandle promise rejections', function (hooks) {
};

// ensure we do not exit this test until the assertion has happened
setTimeout(done, 10);
setTimeout(() => done(), 10);

new RSVPPromise((resolve) => {
setTimeout(resolve);
Expand All @@ -47,10 +48,11 @@ module('unhandle promise rejections', function (hooks) {

if (HAS_NATIVE_PROMISE && HAS_UNHANDLED_REJECTION_HANDLER) {
test('native promises cause an unhandled rejection', function (assert) {
assert.expect(1);
let done = assert.async();

// ensure we do not exit this test until the assertion has happened
setTimeout(done, 10);
setTimeout(() => done(), 10);

new self.Promise((resolve) => {
setTimeout(resolve);
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@
ember-cli-htmlbars "^6.1.1"
ember-destroyable-polyfill "^2.0.3"

"@ember/test-waiters@^3.0.0":
"@ember/test-waiters@^3.0.0", "@ember/test-waiters@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@ember/test-waiters/-/test-waiters-3.0.2.tgz#5b950c580a1891ed1d4ee64f9c6bacf49a15ea6f"
integrity sha512-H8Q3Xy9rlqhDKnQpwt2pzAYDouww4TZIGSI1pZJhM7mQIGufQKuB0ijzn/yugA6Z+bNdjYp1HioP8Y4hn2zazQ==
Expand Down

0 comments on commit c3c83d0

Please sign in to comment.