@@ -17,15 +17,16 @@ module("Unit | Service | alexandria-tags", function (hooks) {
17
17
const service = this . owner . lookup ( "service:alexandria-tags" ) ;
18
18
const store = this . owner . lookup ( "service:store" ) ;
19
19
20
- const document = await store . createRecord ( "document" ) . save ( ) ;
20
+ const documentId = this . server . create ( "document" ) . id ;
21
+ const document = await store . findRecord ( "document" , documentId ) ;
21
22
const tag = await store . createRecord ( "tag" , { name : "T1" } ) . save ( ) ;
22
23
23
24
await service . add ( document , tag ) ;
24
25
25
26
assert . deepEqual (
26
27
requests . map ( ( request ) => request . method ) ,
27
28
[
28
- "POST " , // Create document
29
+ "GET " , // Get document
29
30
"POST" , // Create tag
30
31
"PATCH" , // Add tag to document
31
32
] ,
@@ -39,15 +40,20 @@ module("Unit | Service | alexandria-tags", function (hooks) {
39
40
40
41
const service = this . owner . lookup ( "service:alexandria-tags" ) ;
41
42
const store = this . owner . lookup ( "service:store" ) ;
42
-
43
- const document = await store . createRecord ( "document" ) . save ( ) ;
43
+ const categoryId = this . server . create ( "category" ) . id ;
44
+ const document = await store
45
+ . createRecord ( "document" , {
46
+ category : await store . findRecord ( "category" , categoryId ) ,
47
+ } )
48
+ . save ( ) ;
44
49
const tag = "T1" ;
45
50
46
51
await service . add ( document , tag ) ;
47
52
48
53
assert . deepEqual (
49
54
requests . map ( ( request ) => request . method ) ,
50
55
[
56
+ "GET" , // Get category
51
57
"POST" , // Create document
52
58
"GET" , // search for existing tag
53
59
"POST" , // Create tag
@@ -64,15 +70,16 @@ module("Unit | Service | alexandria-tags", function (hooks) {
64
70
const service = this . owner . lookup ( "service:alexandria-tags" ) ;
65
71
const store = this . owner . lookup ( "service:store" ) ;
66
72
67
- const document = await store . createRecord ( "document" ) . save ( ) ;
73
+ const documentId = this . server . create ( "document" ) . id ;
74
+ const document = await store . findRecord ( "document" , documentId ) ;
68
75
const tag = ( await document . tags ) [ 0 ] ;
69
76
70
77
await service . remove ( document , tag ) ;
71
78
72
79
assert . deepEqual (
73
80
requests . map ( ( request ) => request . method ) ,
74
81
[
75
- "POST " , // Create document
82
+ "GET " , // Get document
76
83
"PATCH" , // Remove tag from document
77
84
] ,
78
85
) ;
0 commit comments