Merge branch 'testing' of https://github.com/ajayyy/SponsorBlockServer into nb-mod-fetch

# Conflicts:
#	src/routes/postSkipSegments.js
#	test/cases/postSkipSegments.js
This commit is contained in:
Ajay Ramachandran
2020-04-30 18:44:49 -04:00
9 changed files with 66 additions and 22 deletions

View File

@@ -130,6 +130,16 @@ describe('postSkipSegments', () => {
});
}).timeout(5000);
it('Should be allowed if youtube thinks duration is 0', (done) => {
request.get(utils.getbaseURL()
+ "/api/postVideoSponsorTimes?videoID=noDuration&startTime=30&endTime=10000&userID=testing", null,
(err, res, body) => {
if (err) done("Couldn't call endpoint");
else if (res.statusCode === 200) done(); // pass
else done("non 200 status code: " + res.statusCode + " ("+body+")");
});
}).timeout(5000);
it('Should be rejected if not a valid videoID', (done) => {
request.get(utils.getbaseURL()
+ "/api/postVideoSponsorTimes?videoID=knownWrongID&startTime=30&endTime=1000000&userID=testing", null,

View File

@@ -4,11 +4,11 @@ var app = express();
var config = require('../src/config.js');
app.post('/ReportChannelWebhook', (req, res) => {
res.status(200);
res.sendStatus(200);
});
app.post('/FirstTimeSubmissionsWebhook', (req, res) => {
res.status(200);
res.sendStatus(200);
});
module.exports = function createMockServer(callback) {

View File

@@ -10,14 +10,35 @@ YouTubeAPI.videos.list({
const YouTubeAPI = {
videos: {
list: (obj, callback) => {
if (obj.videoID === "knownWrongID") {
if (obj.id === "knownWrongID") {
callback(undefined, {
pageInfo: {
totalResults: 0
},
items: []
});
} else {
} if (obj.id === "noDuration") {
callback(undefined, {
pageInfo: {
totalResults: 1
},
items: [
{
contentDetails: {
duration: "PT0S"
},
snippet: {
title: "Example Title",
thumbnails: {
maxres: {
url: "https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png"
}
}
}
}
]
});
} else {
callback(undefined, {
pageInfo: {
totalResults: 1