Skip to content

Commit 6f681d6

Browse files
author
GuustMetz
committed
add api tests
1 parent b5fd961 commit 6f681d6

1 file changed

Lines changed: 126 additions & 0 deletions

File tree

test/api/lhcFills.test.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,132 @@ module.exports = () => {
503503
});
504504
});
505505

506+
it('should return 200 and an LHCFill array for runs duration filter, > 03:00:00', (done) => {
507+
request(server)
508+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]=>&filter[runDuration][limit]=03:00:00')
509+
.expect(200)
510+
.end((err, res) => {
511+
if (err) {
512+
done(err);
513+
return;
514+
}
515+
516+
expect(res.body.data).to.have.lengthOf(1);
517+
expect(res.body.data[0].fillNumber).to.equal(6);
518+
519+
done();
520+
});
521+
});
522+
523+
it('should return 400 when stableBeamEnd filter "from" is greater than "to"', (done) => {
524+
request(server)
525+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[stableBeamsEnd][from]=1647867600000&filter[stableBeamsEnd][to]=1647867600000')
526+
.expect(400)
527+
.end((err, res) => {
528+
if (err) {
529+
done(err);
530+
return;
531+
}
532+
533+
const { errors: [error] } = res.body;
534+
expect(error.title).to.equal('Invalid Attribute');
535+
expect(error.detail).to.equal('"query.filter.stableBeamsEnd.to" must be greater than "ref:from"');
536+
done()
537+
});
538+
});
539+
540+
it('should return 400 when stableBeamStart filter "from" is greater than "to"', (done) => {
541+
request(server)
542+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[stableBeamsStart][from]=1647867600000&filter[stableBeamsStart][to]=1647867600000')
543+
.expect(400)
544+
.end((err, res) => {
545+
if (err) {
546+
done(err);
547+
return;
548+
}
549+
550+
const { errors: [error] } = res.body;
551+
expect(error.title).to.equal('Invalid Attribute');
552+
expect(error.detail).to.equal('"query.filter.stableBeamsStart.to" must be greater than "ref:from"');
553+
done()
554+
});
555+
});
556+
557+
it('should return 200 and a LHCFill array for only "from" filters set for stableBeamStart and end ', (done) => {
558+
const fromValue = 1647867600000;
559+
560+
request(server)
561+
.get("/api/lhcFills?page[offset]=0&page[limit]=15&filter[stableBeamsStart][from]=1647867600000&filter[stableBeamsEnd][from]=1647867600000")
562+
.expect(200)
563+
.end((err, res) => {
564+
if (err) {
565+
done(err);
566+
return;
567+
}
568+
569+
expect(res.body.data).to.have.lengthOf(3);
570+
res.body.data.forEach(fill => {
571+
expect(fill.stableBeamsStart).to.be.at.least(fromValue);
572+
expect(fill.stableBeamsEnd).to.be.at.least(fromValue);
573+
});
574+
575+
done();
576+
});
577+
});
578+
579+
it('should return 200 and a LHCFill array for only "to" filters set for stableBeamStart and end ', (done) => {
580+
const toValue = 2000000000000;
581+
582+
request(server)
583+
.get("/api/lhcFills?page[offset]=0&page[limit]=15&filter[stableBeamsStart][to]=2000000000000&filter[stableBeamsEnd][to]=2000000000000")
584+
.expect(200)
585+
.end((err, res) => {
586+
if (err) {
587+
done(err);
588+
return;
589+
}
590+
591+
expect(res.body.data).to.have.lengthOf(4);
592+
593+
res.body.data.forEach(fill => {
594+
expect(fill.stableBeamsStart).to.be.at.most(toValue);
595+
expect(fill.stableBeamsEnd).to.be.at.most(toValue);
596+
});
597+
done();
598+
});
599+
});
600+
601+
it('should return 200 and a LHCFill array for stableBeamStart and end filter set', (done) => {
602+
request(server)
603+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[stableBeamsStart][from]=1647867600000&filter[stableBeamsStart][to]=1647867600001&filter[stableBeamsEnd][from]=1647961200000&filter[stableBeamsEnd][to]=1647961200001')
604+
.expect(200)
605+
.end((err, res) => {
606+
if (err) {
607+
done(err);
608+
return;
609+
}
610+
611+
expect(res.body.data).to.have.lengthOf(3);
612+
done();
613+
});
614+
});
615+
616+
it('should return 200 and an LHCFill array for runs duration filter, < 00:00:00', (done) => {
617+
request(server)
618+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]=<&filter[runDuration][limit]=00:00:00')
619+
.expect(200)
620+
.end((err, res) => {
621+
if (err) {
622+
done(err);
623+
return;
624+
}
625+
626+
expect(res.body.data).to.have.lengthOf(0);
627+
628+
done();
629+
});
630+
});
631+
506632
it('should return 200 and an LHCFill array for runs duration filter, > 03:00:00', (done) => {
507633
request(server)
508634
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[runDuration][operator]=>&filter[runDuration][limit]=03:00:00')

0 commit comments

Comments
 (0)