@@ -80,7 +80,7 @@ test('Book model and fixture is loaded correctly', function (t) {
80
80
} ) ;
81
81
82
82
test ( 'Returns correct attributes' , function ( t ) {
83
- t . plan ( 7 ) ;
83
+ t . plan ( 9 ) ;
84
84
85
85
sails . request ( {
86
86
url : '/user' ,
@@ -90,6 +90,8 @@ test('Returns correct attributes', function (t) {
90
90
t . fail ( err ) ;
91
91
}
92
92
try {
93
+ t . equal ( res . statusCode , 200 , 'HTTP status code is 200' ) ;
94
+ t . equal ( res . headers [ 'Content-Type' ] , 'application/vnd.api+json' , 'Sends jsonapi mime type' ) ;
93
95
t . ok ( body . data , 'Body contains a "data" property' ) ;
94
96
t . equal ( body . data . length , 2 , 'There are two user objects' ) ;
95
97
t . equal ( body . data [ 0 ] . id , '1' , 'First model id is 1' ) ;
@@ -105,7 +107,7 @@ test('Returns correct attributes', function (t) {
105
107
} ) ;
106
108
107
109
test ( 'Returns correct nested resources' , function ( t ) {
108
- t . plan ( 3 ) ;
110
+ t . plan ( 5 ) ;
109
111
110
112
sails . config . jsonapi . compoundDoc = false ;
111
113
@@ -117,6 +119,8 @@ test('Returns correct nested resources', function (t) {
117
119
t . fail ( err ) ;
118
120
}
119
121
try {
122
+ t . equal ( res . statusCode , 200 , 'HTTP status code is 200' ) ;
123
+ t . equal ( res . headers [ 'Content-Type' ] , 'application/vnd.api+json' , 'Sends jsonapi mime type' ) ;
120
124
t . ok ( body . data [ 0 ] . attributes . books , '"attributes" contains a "books" property' ) ;
121
125
t . equal ( typeof body . data [ 0 ] . attributes . books , 'object' , '"books" is an object' ) ;
122
126
t . deepEqual ( body . data [ 0 ] . attributes . books [ 0 ] . title , 'A Game of Thrones' , '"title" of first book is "A Game of Thrones"' ) ;
@@ -128,7 +132,7 @@ test('Returns correct nested resources', function (t) {
128
132
} ) ;
129
133
130
134
test ( 'Returns relationships for compound document' , function ( t ) {
131
- t . plan ( 4 ) ;
135
+ t . plan ( 6 ) ;
132
136
133
137
sails . config . jsonapi . compoundDoc = true ;
134
138
@@ -140,6 +144,8 @@ test('Returns relationships for compound document', function (t) {
140
144
t . fail ( err ) ;
141
145
}
142
146
try {
147
+ t . equal ( res . statusCode , 200 , 'HTTP status code is 200' ) ;
148
+ t . equal ( res . headers [ 'Content-Type' ] , 'application/vnd.api+json' , 'Sends jsonapi mime type' ) ;
143
149
t . ok ( body . data [ 0 ] . relationships , 'Body contains a "relationships" property' ) ;
144
150
t . ok ( body . data [ 0 ] . relationships . books , 'Relationships contains a "books" property' ) ;
145
151
t . ok ( body . data [ 0 ] . relationships . books . data , 'Relationships contains a "books" property' ) ;
@@ -152,7 +158,7 @@ test('Returns relationships for compound document', function (t) {
152
158
} ) ;
153
159
154
160
test ( 'Returns included data' , function ( t ) {
155
- t . plan ( 8 ) ;
161
+ t . plan ( 10 ) ;
156
162
157
163
sails . config . jsonapi . compoundDoc = true ;
158
164
sails . config . jsonapi . included = true ;
@@ -165,6 +171,8 @@ test('Returns included data', function (t) {
165
171
t . fail ( err ) ;
166
172
}
167
173
try {
174
+ t . equal ( res . statusCode , 200 , 'HTTP status code is 200' ) ;
175
+ t . equal ( res . headers [ 'Content-Type' ] , 'application/vnd.api+json' , 'Sends jsonapi mime type' ) ;
168
176
t . ok ( body . included , 'Body contains an "included" property' ) ;
169
177
t . equal ( body . included . length , 3 , 'Three books are included' ) ;
170
178
t . ok ( body . included [ 0 ] . type , '"included" contains a "type" property' ) ;
@@ -181,7 +189,7 @@ test('Returns included data', function (t) {
181
189
} ) ;
182
190
183
191
test ( 'Does not return included data if "included = false"' , function ( t ) {
184
- t . plan ( 2 ) ;
192
+ t . plan ( 4 ) ;
185
193
186
194
sails . config . jsonapi . compoundDoc = true ;
187
195
sails . config . jsonapi . included = false ;
@@ -194,6 +202,8 @@ test('Does not return included data if "included = false"', function (t) {
194
202
t . fail ( err ) ;
195
203
}
196
204
try {
205
+ t . equal ( res . statusCode , 200 , 'HTTP status code is 200' ) ;
206
+ t . equal ( res . headers [ 'Content-Type' ] , 'application/vnd.api+json' , 'Sends jsonapi mime type' ) ;
197
207
t . notOk ( body . included , 'Body does not contain an "included" property' ) ;
198
208
t . ok ( body . data [ 0 ] . relationships , 'But it still has a "relationships" property (compound doc)' ) ;
199
209
} catch ( err ) {
0 commit comments