Skip to content

Commit a782a22

Browse files
committed
add strict assertions for task
1 parent fb36e50 commit a782a22

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

test/integration/tasks.test.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ describe('Tasks', function () {
3232
startedOn: 4567,
3333
status: 'active',
3434
percentCompleted: 10,
35-
participants: [appOwner.username],
35+
participants: [],
36+
assignee: appOwner.username,
3637
completionAward: { [DINERO]: 3, [NEELAM]: 300 },
3738
lossRate: { [DINERO]: 1 },
3839
isNoteworthy: true
@@ -115,7 +116,13 @@ describe('Tasks', function () {
115116
expect(res.body.message).to.equal('Tasks returned successfully!')
116117
expect(res.body.tasks).to.be.a('array')
117118
const taskWithParticipants = res.body.tasks[0]
118-
expect(taskWithParticipants.participants).to.have.members([appOwner.username])
119+
120+
if (taskWithParticipants.type === 'group') {
121+
expect(taskWithParticipants.participants).to.include(appOwner.username)
122+
} else {
123+
expect(taskWithParticipants.assignee).to.equal(appOwner.username)
124+
}
125+
119126
return done()
120127
})
121128
})
@@ -254,12 +261,21 @@ describe('Tasks', function () {
254261
it('Should return 200 when username is valid', function (done) {
255262
chai
256263
.request(app)
257-
.get('/tasks/sagar')
264+
.get(`/tasks/${appOwner.username}`)
258265
.end((err, res) => {
259266
if (err) { return done(err) }
260267
expect(res).to.have.status(200)
261268
expect(res.body).to.be.a('object')
262269
expect(res.body.message).to.equal('Tasks returned successfully!')
270+
271+
const task1 = res.body.tasks[0]
272+
273+
if (task1.type === 'group') {
274+
expect(task1.participants).to.include(appOwner.username)
275+
} else {
276+
expect(task1.assignee).to.equal(appOwner.username)
277+
}
278+
263279
expect(res.body.tasks).to.be.a('array')
264280
return done()
265281
})

0 commit comments

Comments
 (0)