Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Update tests for emberjs/rfcs#232
Browse files Browse the repository at this point in the history
  • Loading branch information
mloar committed Oct 21, 2019
1 parent 1c264db commit f2977cb
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 128 deletions.
19 changes: 10 additions & 9 deletions tests/unit/adapters/application-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { moduleFor, test } from 'ember-qunit';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

moduleFor('adapter:application', 'Unit | Adapter | application', {
integration: true
});
module('Unit | Adapter | application', function(hooks) {
setupTest(hooks);

// Replace this with your real tests.
test('buildQuery appends page size', function(assert) {
let adapter = this.subject();
assert.deepEqual(adapter.buildQuery({}), { "page": { "size": 0 } });
assert.deepEqual(adapter.buildQuery({"include": "sources"}), { "include": "sources", "page": { "size": 0 } });
// Replace this with your real tests.
test('buildQuery appends page size', function(assert) {
let adapter = this.owner.lookup('adapter:application');
assert.deepEqual(adapter.buildQuery({}), { "page": { "size": 0 } });
assert.deepEqual(adapter.buildQuery({"include": "sources"}), { "include": "sources", "page": { "size": 0 } });
});
});
125 changes: 63 additions & 62 deletions tests/unit/controllers/index-test.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
import { moduleFor, test } from 'ember-qunit';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

moduleFor('controller:index', 'Unit | Controller | index', {
integration: true
});
module('Unit | Controller | index', function(hooks) {
setupTest(hooks);

// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.subject();
assert.ok(controller);
});
// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.owner.lookup('controller:index');
assert.ok(controller);
});

test('works are sorted by author', function(assert) {
let controller = this.subject();
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);
test('works are sorted by author', function(assert) {
let controller = this.owner.lookup('controller:index');
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);

assert.deepEqual(controller.get('sorted'), [
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"}
]);
});
assert.deepEqual(controller.get('sorted'), [
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"}
]);
});

test('works are sorted by title', function(assert) {
let controller = this.subject();
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);
test('works are sorted by title', function(assert) {
let controller = this.owner.lookup('controller:index');
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);

controller.send('changesort', 'title');
assert.deepEqual(controller.get('sorted'), [
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"}
]);
});
controller.send('changesort', 'title');
assert.deepEqual(controller.get('sorted'), [
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"}
]);
});

test('works are sorted by issue', function(assert) {
let controller = this.subject();
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);
test('works are sorted by issue', function(assert) {
let controller = this.owner.lookup('controller:index');
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);

controller.send('changesort', 'issue');
assert.deepEqual(controller.get('sorted'), [
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"}
]);
});
controller.send('changesort', 'issue');
assert.deepEqual(controller.get('sorted'), [
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"}
]);
});

test('works are reverse sorted by bookpuller', function(assert) {
let controller = this.subject();
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);
test('works are reverse sorted by bookpuller', function(assert) {
let controller = this.owner.lookup('controller:index');
controller.set('model', [
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);

controller.send('changesort', 'bookpuller');
controller.send('changesort', 'bookpuller');
controller.send('changesort', 'bookpuller');
controller.send('changesort', 'bookpuller');

assert.deepEqual(controller.get('sorted'), [
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);
assert.deepEqual(controller.get('sorted'), [
{"id": "3", "author": "Eve", "bookpuller": "Jack", "comments": "Hi", "issue": "5", "title": "Veni Vedi Vici", "volume": "2017"},
{"id": "1", "author": "Bob", "bookpuller": null, "comments": null, "issue": "2", "title": "Res Ipsa Loquitur", "volume": "2018"},
{"id": "2", "author": "Alice", "bookpuller": null, "comments": null, "issue": "1", "title": "In Vino Veritas", "volume": "2018"}
]);
});
});
65 changes: 33 additions & 32 deletions tests/unit/controllers/work/sources-test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import { moduleFor, test } from 'ember-qunit';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

moduleFor('controller:work/sources', 'Unit | Controller | work/sources', {
integration: true
});
module('Unit | Controller | work/sources', function(hooks) {
setupTest(hooks);

test('sources are filtered', function(assert) {
let controller = this.subject();
controller.set('model', [
{"id": "1", "citation": "New York Times", "comments": null, "ordered": null, "status": "N", "type": "P", "url": "null"},
{"id": "2", "citation": "Blackstone's Commentaries", "comments": null, "ordered": null, "status": "N", "type": "B", "url": "null"},
{"id": "3", "citation": "Roe v. Wade", "comments": null, "ordered": null, "status": "N", "type": "C", "url": "null"},
{"id": "4", "citation": "U. Ill. L. Rev.", "comments": null, "ordered": null, "status": "N", "type": "J", "url": "null"},
{"id": "5", "citation": "H.R. 5", "comments": null, "ordered": null, "status": "N", "type": "L", "url": "null"},
{"id": "6", "citation": "Zombo.com", "comments": null, "ordered": null, "status": "N", "type": "M", "url": "null"}
]);
test('sources are filtered', function(assert) {
let controller = this.owner.lookup('controller:work/sources');
controller.set('model', [
{"id": "1", "citation": "New York Times", "comments": null, "ordered": null, "status": "N", "type": "P", "url": "null"},
{"id": "2", "citation": "Blackstone's Commentaries", "comments": null, "ordered": null, "status": "N", "type": "B", "url": "null"},
{"id": "3", "citation": "Roe v. Wade", "comments": null, "ordered": null, "status": "N", "type": "C", "url": "null"},
{"id": "4", "citation": "U. Ill. L. Rev.", "comments": null, "ordered": null, "status": "N", "type": "J", "url": "null"},
{"id": "5", "citation": "H.R. 5", "comments": null, "ordered": null, "status": "N", "type": "L", "url": "null"},
{"id": "6", "citation": "Zombo.com", "comments": null, "ordered": null, "status": "N", "type": "M", "url": "null"}
]);

assert.deepEqual(controller.get('books'), [
{"id": "2", "citation": "Blackstone's Commentaries", "comments": null, "ordered": null, "status": "N", "type": "B", "url": "null"}
]);
assert.deepEqual(controller.get('books'), [
{"id": "2", "citation": "Blackstone's Commentaries", "comments": null, "ordered": null, "status": "N", "type": "B", "url": "null"}
]);

assert.deepEqual(controller.get('cases'), [
{"id": "3", "citation": "Roe v. Wade", "comments": null, "ordered": null, "status": "N", "type": "C", "url": "null"},
]);
assert.deepEqual(controller.get('journals'), [
{"id": "4", "citation": "U. Ill. L. Rev.", "comments": null, "ordered": null, "status": "N", "type": "J", "url": "null"},
]);
assert.deepEqual(controller.get('legislative'), [
{"id": "5", "citation": "H.R. 5", "comments": null, "ordered": null, "status": "N", "type": "L", "url": "null"}
]);
assert.deepEqual(controller.get('miscellaneous'), [
{"id": "6", "citation": "Zombo.com", "comments": null, "ordered": null, "status": "N", "type": "M", "url": "null"}
]);
assert.deepEqual(controller.get('periodicals'), [
{"id": "1", "citation": "New York Times", "comments": null, "ordered": null, "status": "N", "type": "P", "url": "null"}
]);
assert.deepEqual(controller.get('cases'), [
{"id": "3", "citation": "Roe v. Wade", "comments": null, "ordered": null, "status": "N", "type": "C", "url": "null"},
]);
assert.deepEqual(controller.get('journals'), [
{"id": "4", "citation": "U. Ill. L. Rev.", "comments": null, "ordered": null, "status": "N", "type": "J", "url": "null"},
]);
assert.deepEqual(controller.get('legislative'), [
{"id": "5", "citation": "H.R. 5", "comments": null, "ordered": null, "status": "N", "type": "L", "url": "null"}
]);
assert.deepEqual(controller.get('miscellaneous'), [
{"id": "6", "citation": "Zombo.com", "comments": null, "ordered": null, "status": "N", "type": "M", "url": "null"}
]);
assert.deepEqual(controller.get('periodicals'), [
{"id": "1", "citation": "New York Times", "comments": null, "ordered": null, "status": "N", "type": "P", "url": "null"}
]);
});
});
2 changes: 0 additions & 2 deletions tests/unit/models/source-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { get } from '@ember/object';
//import { run } from '@ember/runloop';

module('Unit | Model | source', function(hooks) {
setupTest(hooks);

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/models/work-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { get } from '@ember/object';
//import { run } from '@ember/runloop';

module('Unit | Model | work', function(hooks) {
setupTest(hooks);

Expand Down
15 changes: 8 additions & 7 deletions tests/unit/routes/index-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { moduleFor, test } from 'ember-qunit';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

moduleFor('route:index', 'Unit | Route | index', {
integration: true
});
module('Unit | Route | index', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
test('it exists', function(assert) {
let route = this.owner.lookup('route:index');
assert.ok(route);
});
});
15 changes: 8 additions & 7 deletions tests/unit/routes/work-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { moduleFor, test } from 'ember-qunit';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

moduleFor('route:work', 'Unit | Route | work', {
integration: true
});
module('Unit | Route | work', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
test('it exists', function(assert) {
let route = this.owner.lookup('route:work');
assert.ok(route);
});
});
15 changes: 8 additions & 7 deletions tests/unit/routes/work/sources-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { moduleFor, test } from 'ember-qunit';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

moduleFor('route:work/sources', 'Unit | Route | work/sources', {
integration: true
});
module('Unit | Route | work/sources', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
test('it exists', function(assert) {
let route = this.owner.lookup('route:work/sources');
assert.ok(route);
});
});

0 comments on commit f2977cb

Please sign in to comment.