Skip to content

Commit 4e68523

Browse files
committed
[O2B-1506] Fixed > and < added tests
1 parent 637ad11 commit 4e68523

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

lib/usecases/lhcFill/GetAllLhcFillsUseCase.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class GetAllLhcFillsUseCase {
7373
// Include 00:00:00 = 0 = null AND everything above 00:00:00 which is more or less than 0.
7474
queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator(runDuration.operator, 0);
7575
queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator('=', null);
76+
} else if ((runDuration.operator === '>' || runDuration.operator === '<') && Number(runDuration.limit) === 0) {
77+
queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator(runDuration.operator, 0);
7678
} else if (Number(runDuration.limit) === 0) {
7779
queryBuilder.whereAssociation('statistics', 'runsCoverage').applyOperator(runDuration.operator, null);
7880
} else {

test/api/lhcFills.test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,56 @@ module.exports = () => {
453453
});
454454
});
455455

456+
it('should return 200 and an LHCFill array for runs duration filter, = 00:00:00', (done) => {
457+
request(server)
458+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]==&filter[runDuration][limit]=00:00:00')
459+
.expect(200)
460+
.end((err, res) => {
461+
if (err) {
462+
done(err);
463+
return;
464+
}
465+
466+
expect(res.body.data).to.have.lengthOf(4);
467+
expect(res.body.data[0].fillNumber).to.equal(5);
468+
469+
done();
470+
});
471+
});
472+
473+
it('should return 200 and an LHCFill array for runs duration filter, > 00:00:00', (done) => {
474+
request(server)
475+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]=>&filter[runDuration][limit]=00:00:00')
476+
.expect(200)
477+
.end((err, res) => {
478+
if (err) {
479+
done(err);
480+
return;
481+
}
482+
483+
expect(res.body.data).to.have.lengthOf(1);
484+
expect(res.body.data[0].fillNumber).to.equal(6);
485+
486+
done();
487+
});
488+
});
489+
490+
it('should return 200 and an LHCFill array for runs duration filter, < 00:00:00', (done) => {
491+
request(server)
492+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]=<&filter[runDuration][limit]=00:00:00')
493+
.expect(200)
494+
.end((err, res) => {
495+
if (err) {
496+
done(err);
497+
return;
498+
}
499+
500+
expect(res.body.data).to.have.lengthOf(0);
501+
502+
done();
503+
});
504+
});
505+
456506
it('should return 200 and an LHCFill array for runs duration filter, > 03:00:00', (done) => {
457507
request(server)
458508
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]=>&filter[runDuration][limit]=03:00:00')

0 commit comments

Comments
 (0)