Skip to content

Commit d7dbca0

Browse files
committed
fix(utils): Fix bug introduced by #265 and add test case for remote type
1 parent 8a775d4 commit d7dbca0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function getTypeFromContext (context) {
148148

149149
const returns = [].concat(context.method.returns)
150150
for (var i = 0, l = returns.length; i < l; i++) {
151-
if (typeof returns[i] === 'object' && returns[i].root === true) continue
151+
if (typeof returns[i] !== 'object' || returns[i].root !== true) continue
152152
return returns[i].type
153153
}
154154
}

test/remoteMethods.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ describe('loopback json api remote methods', function () {
185185
expect(err).to.equal(null)
186186
expect(res.body).to.be.an('object')
187187
expect(res.body.data).to.be.an('array').with.lengthOf(1)
188+
expect(res.body.data[0].type).to.equal('archives')
188189
expect(res.body.data[0].id).to.equal(archiveData.id + '')
189190
expect(res.body.data[0].attributes).to.deep.equal({
190191
raw: archiveData.raw,
@@ -205,6 +206,7 @@ describe('loopback json api remote methods', function () {
205206

206207
expect(res.body.data).to.be.an('object')
207208
expect(res.body.data.id).to.equal(postData.id + '')
209+
expect(res.body.data.type).to.equal('posts')
208210
expect(res.body.data.attributes).to.deep.equal({
209211
title: postData.title,
210212
content: postData.content

0 commit comments

Comments
 (0)