more tests

This commit is contained in:
Joe Dowd 2020-08-31 04:17:50 +01:00
parent 9c9c2a23cc
commit 2c32460a6e
2 changed files with 25 additions and 0 deletions

View file

@ -2,6 +2,7 @@ const hashPrefixTester = require('../utils/hashPrefixTester.js');
const getSegments = require('./getSkipSegments.js').cleanGetSegments;
const databases = require('../databases/databases.js');
const logger = require('../utils/logger.js');
const db = databases.db;
module.exports = async function (req, res) {

View file

@ -100,6 +100,30 @@ describe('getSegmentsByHash', () => {
});
});
it('Should return 404 for no hash', (done) => {
request.get(utils.getbaseURL()
+ '/api/skipSegments/?categories=["shilling"]', null,
(err, res, body) => {
if (err) done("Couldn't call endpoint");
else if (res.statusCode !== 404) done("expected 404, got " + res.statusCode);
else {
done(); // pass
}
});
});
it('Should return 500 for bad format categories', (done) => { // should probably be 400
request.get(utils.getbaseURL()
+ '/api/skipSegments/?categories=shilling', null,
(err, res, body) => {
if (err) done("Couldn't call endpoint");
else if (res.statusCode !== 500) done("expected 500 got " + res.statusCode);
else {
done(); // pass
}
});
});
it('Should be able to get multiple videos', (done) => {
request.get(utils.getbaseURL()
+ '/api/skipSegments/fdaf?categories=["sponsor","intro"]', null,