This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
/
index-test.js
75 lines (64 loc) · 4.41 KB
/
index-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Controller | index', function(hooks) {
setupTest(hooks);
// 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.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"}
]);
});
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"}
]);
});
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"}
]);
});
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');
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"}
]);
});
});