Skip to content

Commit

Permalink
feat(test): improved tests according to new feat
Browse files Browse the repository at this point in the history
  • Loading branch information
rocknrolla777 committed Jun 22, 2017
1 parent 6e1f92c commit 4f63728
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/hasMany.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ describe('loopback json api hasMany relationships', function () {
expect(res.body.included[0]).to.have.all.keys(
'type',
'id',
'attributes'
'attributes',
'relationships'
)
expect(res.body.included[0].type).to.equal('comments')
expect(res.body.included[0].id).to.equal('1')
Expand Down Expand Up @@ -275,6 +276,13 @@ describe('loopback json api hasMany relationships', function () {
attributes: {
title: 'My comment',
comment: 'My comment text'
},
relationships: {
replies: {
links: {
related: res.body.included[0].relationships.replies.links.related
}
}
}
})
expect(res.body.included[1]).to.deep.equal({
Expand All @@ -283,6 +291,13 @@ describe('loopback json api hasMany relationships', function () {
attributes: {
title: 'My second comment',
comment: 'My second comment text'
},
relationships: {
replies: {
links: {
related: res.body.included[1].relationships.replies.links.related
}
}
}
})
done()
Expand Down Expand Up @@ -368,7 +383,8 @@ describe('loopback json api hasMany relationships', function () {
expect(res.body.included[0]).to.have.all.keys(
'type',
'id',
'attributes'
'attributes',
'relationships'
)
expect(res.body.included[0].type).to.equal('comments')
expect(res.body.included[0].id).to.equal('1')
Expand Down
29 changes: 29 additions & 0 deletions test/hasManyRelationships.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ describe('loopback json api hasMany relationships', function () {
attributes: {
firstName: 'Joe',
lastName: 'Shmoe'
},
relationships: {
posts: {
links: {
related: res.body.included[0].relationships.posts.links.related
}
}
}
})
expect(res.body.included[1]).to.deep.equal({
Expand All @@ -112,6 +119,17 @@ describe('loopback json api hasMany relationships', function () {
attributes: {
title: 'My comment',
comment: 'My comment text'
},
relationships: {
post: {
data: {
id: 1,
type: 'posts'
},
links: {
related: res.body.included[1].relationships.post.links.related
}
}
}
})
expect(res.body.included[2]).to.deep.equal({
Expand All @@ -120,6 +138,17 @@ describe('loopback json api hasMany relationships', function () {
attributes: {
title: 'My second comment',
comment: 'My second comment text'
},
relationships: {
post: {
data: {
id: 1,
type: 'posts'
},
links: {
related: res.body.included[2].relationships.post.links.related
}
}
}
})
done()
Expand Down

0 comments on commit 4f63728

Please sign in to comment.