-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathusers-delete-test.js
55 lines (41 loc) · 1.42 KB
/
users-delete-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
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import {
makeList,
mockDelete,
mockFindAll,
setupFactoryGuy,
} from 'ember-data-factory-guy';
import { visit, click } from '@ember/test-helpers';
module('Acceptance | Users Delete', function (hooks) {
setupApplicationTest(hooks);
setupFactoryGuy(hooks);
test('Deleting any user with modelName', async function (assert) {
mockFindAll('user', 2);
mockDelete('user');
await visit('/users');
assert.dom('li.user').exists({ count: 2 });
await click('li.user:nth-child(1) button');
assert.dom('li.user').exists({ count: 1 });
await click('li.user:nth-child(1) button');
assert.dom('li.user').doesNotExist();
});
test('Deleting a user with model', async function (assert) {
const users = makeList('user', 2);
const user = users[0];
mockFindAll('user').returns({ models: users });
mockDelete(user);
await visit('/users');
assert.dom('li.user').exists({ count: 2 });
await click('li.user:nth-child(1) button');
assert.dom('li.user').exists({ count: 1 });
});
test('Deleting a user with modelName and id', async function (assert) {
mockFindAll('user', 2);
mockDelete('user', '1');
await visit('/users');
assert.dom('li.user').exists({ count: 2 });
await click('li.user:nth-child(1) button');
assert.dom('li.user').exists({ count: 1 });
});
});