Skip to content

Commit 4f63728

Browse files
committed
feat(test): improved tests according to new feat
1 parent 6e1f92c commit 4f63728

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

test/hasMany.test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ describe('loopback json api hasMany relationships', function () {
242242
expect(res.body.included[0]).to.have.all.keys(
243243
'type',
244244
'id',
245-
'attributes'
245+
'attributes',
246+
'relationships'
246247
)
247248
expect(res.body.included[0].type).to.equal('comments')
248249
expect(res.body.included[0].id).to.equal('1')
@@ -275,6 +276,13 @@ describe('loopback json api hasMany relationships', function () {
275276
attributes: {
276277
title: 'My comment',
277278
comment: 'My comment text'
279+
},
280+
relationships: {
281+
replies: {
282+
links: {
283+
related: res.body.included[0].relationships.replies.links.related
284+
}
285+
}
278286
}
279287
})
280288
expect(res.body.included[1]).to.deep.equal({
@@ -283,6 +291,13 @@ describe('loopback json api hasMany relationships', function () {
283291
attributes: {
284292
title: 'My second comment',
285293
comment: 'My second comment text'
294+
},
295+
relationships: {
296+
replies: {
297+
links: {
298+
related: res.body.included[1].relationships.replies.links.related
299+
}
300+
}
286301
}
287302
})
288303
done()
@@ -368,7 +383,8 @@ describe('loopback json api hasMany relationships', function () {
368383
expect(res.body.included[0]).to.have.all.keys(
369384
'type',
370385
'id',
371-
'attributes'
386+
'attributes',
387+
'relationships'
372388
)
373389
expect(res.body.included[0].type).to.equal('comments')
374390
expect(res.body.included[0].id).to.equal('1')

test/hasManyRelationships.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ describe('loopback json api hasMany relationships', function () {
104104
attributes: {
105105
firstName: 'Joe',
106106
lastName: 'Shmoe'
107+
},
108+
relationships: {
109+
posts: {
110+
links: {
111+
related: res.body.included[0].relationships.posts.links.related
112+
}
113+
}
107114
}
108115
})
109116
expect(res.body.included[1]).to.deep.equal({
@@ -112,6 +119,17 @@ describe('loopback json api hasMany relationships', function () {
112119
attributes: {
113120
title: 'My comment',
114121
comment: 'My comment text'
122+
},
123+
relationships: {
124+
post: {
125+
data: {
126+
id: 1,
127+
type: 'posts'
128+
},
129+
links: {
130+
related: res.body.included[1].relationships.post.links.related
131+
}
132+
}
115133
}
116134
})
117135
expect(res.body.included[2]).to.deep.equal({
@@ -120,6 +138,17 @@ describe('loopback json api hasMany relationships', function () {
120138
attributes: {
121139
title: 'My second comment',
122140
comment: 'My second comment text'
141+
},
142+
relationships: {
143+
post: {
144+
data: {
145+
id: 1,
146+
type: 'posts'
147+
},
148+
links: {
149+
related: res.body.included[2].relationships.post.links.related
150+
}
151+
}
123152
}
124153
})
125154
done()

0 commit comments

Comments
 (0)