-
-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathemployee-view-test.js
95 lines (79 loc) · 3.19 KB
/
employee-view-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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { module, test } from 'qunit';
import {
build,
buildList,
make,
mockFindRecord,
setupFactoryGuy,
} from 'ember-data-factory-guy';
import { setupApplicationTest } from 'ember-qunit';
import { visit } from '@ember/test-helpers';
module('Acceptance | Employee View ( model-fragments )', function (hooks) {
setupApplicationTest(hooks);
setupFactoryGuy(hooks);
test('Show employee by make(ing) a model ( with hasMany fragment added manually ) and using returns with that model', async function (assert) {
let departmentEmployments = buildList('department-employment', 2).get();
let employee = make('employee', { departmentEmployments });
mockFindRecord('employee').returns({ model: employee });
await visit('/employee/' + employee.get('id'));
assert
.dom('.name')
.containsText(
`${employee.get('name.firstName')} ${employee.get('name.lastName')}`
);
assert
.dom('.department-employment')
.exists({ count: 2 }, 'fragment array works');
});
test('Show employee by make(ing) a model ( with belongsTo fragment added manually ) and using returns with that model', async function (assert) {
let name = make('name', { firstName: 'Joe', lastName: 'Black' });
let employee = make('employee', { name });
mockFindRecord('employee').returns({ model: employee });
await visit('/employee/' + employee.get('id'));
assert
.dom('.name')
.containsText(
`${employee.get('name.firstName')} ${employee.get('name.lastName')}`
);
});
test('Show employee by make(ing) a model and using returns with that model', async function (assert) {
let employee = make('employee', 'with_department_employments');
mockFindRecord('employee').returns({ model: employee });
await visit('/employee/' + employee.get('id'));
assert
.dom('.name')
.containsText(
`${employee.get('name.firstName')} ${employee.get('name.lastName')}`
);
assert
.dom('.department-employment')
.exists({ count: 2 }, 'fragment array works');
});
test('Show employee by build(ing) json and using returns with that json', async function (assert) {
let employee = build('employee', 'with_department_employments');
mockFindRecord('employee').returns({ json: employee });
await visit('/employee/' + employee.get('id'));
assert
.dom('.name')
.containsText(
`${employee.get('name').first_name} ${employee.get('name').last_name}`
);
assert
.dom('.department-employment')
.exists({ count: 2 }, 'fragment array works');
});
test('Show employee by build(ing) json ( with hasMany fragment added manually ) and using returns with that json', async function (assert) {
let departmentEmployments = buildList('department-employment', 2).get();
let employee = build('employee', { departmentEmployments });
mockFindRecord('employee').returns({ json: employee });
await visit('/employee/' + employee.get('id'));
assert
.dom('.name')
.containsText(
`${employee.get('name').first_name} ${employee.get('name').last_name}`
);
assert
.dom('.department-employment')
.exists({ count: 2 }, 'fragment array works');
});
});