Skip to content

Commit

Permalink
stricter tests on search by id
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mcl committed Nov 21, 2024
1 parent 3f4fbb8 commit 229fdce
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unit/forge/routes/api/search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ describe('Search API', function () {
app.db.models.Application.byTeam.called.should.be.true()
app.db.models.Project.byTeam.called.should.be.false()
app.db.models.Device.byTeam.called.should.be.false()

// ensure query was not passed to byTeam & that applicationId was passed
const args = app.db.models.Application.byTeam.getCall(0).args
args[1].should.not.have.property('query')
args[1].should.have.property('applicationId', TestObjects.AppOne.id) // actual id, not hashid
})

it('search by instance id returns only one instance & does not query other tables', async function () {
Expand All @@ -233,6 +238,11 @@ describe('Search API', function () {
app.db.models.Application.byTeam.called.should.be.false()
app.db.models.Project.byTeam.called.should.be.true()
app.db.models.Device.byTeam.called.should.be.false()

// ensure query was not passed to byTeam & that instanceId was passed
const args = app.db.models.Project.byTeam.getCall(0).args
args[1].should.not.have.property('query')
args[1].should.have.property('instanceId', TestObjects.App1Instance1.id)
})

it('search by device id returns only one device & does not query other tables', async function () {
Expand All @@ -251,6 +261,11 @@ describe('Search API', function () {
app.db.models.Application.byTeam.called.should.be.false()
app.db.models.Project.byTeam.called.should.be.false()
app.db.models.Device.byTeam.called.should.be.true()

// ensure query was not passed to byTeam & that deviceId was passed
const args = app.db.models.Device.byTeam.getCall(0).args
args[1].should.not.have.property('query')
args[1].should.have.property('deviceId', TestObjects.App1Instance1Device1.id)
})

it('search with blank query returns nothing', async function () {
Expand Down

0 comments on commit 229fdce

Please sign in to comment.