Skip to content

Commit 4152a3a

Browse files
committed
chore(tests): Add test for duplicate fix
1 parent 6c8ac19 commit 4152a3a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/hasManyRelationships.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,29 @@ describe('loopback json api hasMany relationships', function () {
113113
})
114114
})
115115
})
116+
117+
describe('Duplicate models in `includes`', function () {
118+
beforeEach(function () {
119+
const Foo = ds.createModel('foo', {title: String})
120+
app.model(Foo)
121+
const Bar = ds.createModel('bar', {title: String})
122+
app.model(Bar)
123+
Foo.hasMany(Bar)
124+
Foo.belongsTo(Bar)
125+
126+
return Promise.all([
127+
Foo.create({title: 'one', barId: 1}),
128+
Bar.create({title: 'one', barId: 1, fooId: 1})
129+
])
130+
})
131+
132+
it('should not occur', function () {
133+
return request(app).get('/foos/1/?include=bars,bar')
134+
.expect(200)
135+
.then(function (res) {
136+
expect(res.body.included.length).to.equal(1,
137+
'Should be exactly 1 item in included array')
138+
})
139+
})
140+
})
116141
})

0 commit comments

Comments
 (0)