Skip to content

Commit 9f050b6

Browse files
committed
fix error checking in tests and model construction
1 parent dd9b5a0 commit 9f050b6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

test/belongsToPolymorphic.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('loopback json api belongsTo polymorphic relationships', function () {
5858
request(app).get('/files/1')
5959
.end(function (err, res) {
6060
expect(err).to.equal(null);
61-
expect(res.body.errors).to.equal(undefined);
61+
expect(res.body).to.not.have.key('errors');
6262
expect(res.body.data.relationships.parent).to.be.an('object');
6363
done();
6464
});
@@ -68,7 +68,7 @@ describe('loopback json api belongsTo polymorphic relationships', function () {
6868
request(app).get('/files/1?include=parent')
6969
.end(function (err, res) {
7070
expect(err).to.equal(null);
71-
expect(res.body.errors).to.equal(undefined);
71+
expect(res.body).to.not.have.key('errors');
7272
expect(res.body.included).to.be.an('array');
7373
expect(res.body.included[0].type).to.equal('posts');
7474
expect(res.body.included[0].id).to.equal('1');
@@ -80,11 +80,11 @@ describe('loopback json api belongsTo polymorphic relationships', function () {
8080
request(app).get('/files/1')
8181
.end(function (err, res) {
8282
expect(err).to.equal(null);
83-
expect(res.body.errors).to.equal(undefined);
83+
expect(res.body).to.not.have.key('errors');
8484
request(app).get(res.body.data.relationships.parent.links.related.split('api')[1])
8585
.end(function (err, res) {
8686
expect(err).to.equal(null);
87-
expect(res.body.errors).to.equal(undefined);
87+
expect(res.body).to.not.have.key('errors');
8888
expect(res.body.data.type).to.equal('posts');
8989
expect(res.body.data.id).to.equal('1');
9090
done();

test/hasManyPolymorphic.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('loopback json api hasMany polymorphic relationships', function () {
4545
content: 'Content'
4646
}, function (err, post) {
4747
expect(err).to.equal(null);
48-
File.create({
48+
post.files.create({
4949
fileName: 'blah.jpg',
5050
parentId: post.id,
5151
parentType: 'post'
@@ -57,7 +57,7 @@ describe('loopback json api hasMany polymorphic relationships', function () {
5757
request(app).get('/posts/1')
5858
.end(function (err, res) {
5959
expect(err).to.equal(null);
60-
expect(res.body.errors).to.equal(undefined);
60+
expect(res.body).to.not.have.key('errors');
6161
expect(res.body.data.relationships.files).to.be.an('object');
6262
done();
6363
});
@@ -67,7 +67,7 @@ describe('loopback json api hasMany polymorphic relationships', function () {
6767
request(app).get('/posts/1?include=files')
6868
.end(function (err, res) {
6969
expect(err).to.equal(null);
70-
expect(res.body.errors).to.equal(undefined);
70+
expect(res.body).to.not.have.key('errors');
7171
expect(res.body.included).to.be.an('array');
7272
expect(res.body.included[0].type).to.equal('files');
7373
expect(res.body.included[0].id).to.equal('1');
@@ -79,11 +79,11 @@ describe('loopback json api hasMany polymorphic relationships', function () {
7979
request(app).get('/posts/1')
8080
.end(function (err, res) {
8181
expect(err).to.equal(null);
82-
expect(res.body.errors).to.equal(undefined);
82+
expect(res.body).to.not.have.key('errors');
8383
request(app).get(res.body.data.relationships.files.links.related.split('api')[1])
8484
.end(function (err, res) {
8585
expect(err).to.equal(null);
86-
expect(res.body.errors).to.equal(undefined);
86+
expect(res.body).to.not.have.key('errors');
8787
expect(res.body.data).to.be.an('array');
8888
expect(res.body.data[0].type).to.equal('files');
8989
expect(res.body.data[0].id).to.equal('1');

0 commit comments

Comments
 (0)