mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-10 13:37:01 +03:00
more edge cast test cases
- check for null instead of 0 #267 - check that parameter specifying multiple overrides repeating parameters
This commit is contained in:
@@ -331,4 +331,21 @@ describe('getSegmentInfo', () => {
|
|||||||
})
|
})
|
||||||
.catch(err => "Couldn't call endpoint");
|
.catch(err => "Couldn't call endpoint");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should not parse repeated UUID if UUIDs present', (done: Done) => {
|
||||||
|
fetch(getbaseURL() + `/api/segmentInfo?UUID=${downvotedID}&UUID=${lockedupID}&UUIDs=[\"${upvotedID}\"]`)
|
||||||
|
.then(async res => {
|
||||||
|
if (res.status !== 200) done("Status code was: " + res.status);
|
||||||
|
else {
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.length === 1 &&
|
||||||
|
(data[0].videoID === "upvoted" && data[0].votes === 2)) {
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
done("Received incorrect body: " + (await res.text()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => "Couldn't call endpoint");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -292,4 +292,21 @@ describe('getSkipSegments', () => {
|
|||||||
})
|
})
|
||||||
.catch(err => ("Couldn't call endpoint"));
|
.catch(err => ("Couldn't call endpoint"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should be able to get, categories param overriding repeating category', (done: Done) => {
|
||||||
|
fetch(getbaseURL() + "/api/skipSegments?videoID=testtesttest&categories=[\"sponsor\"]&category=intro")
|
||||||
|
.then(async res => {
|
||||||
|
if (res.status !== 200) done("Status code was: " + res.status);
|
||||||
|
else {
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.length === 1 && data[0].segment[0] === 1 && data[0].segment[1] === 11
|
||||||
|
&& data[0].category === "sponsor" && data[0].UUID === "1-uuid-0") {
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
done("Received incorrect body: " + (await res.text()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => ("Couldn't call endpoint"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -158,4 +158,18 @@ describe('getUserInfo', () => {
|
|||||||
})
|
})
|
||||||
.catch(err => ("couldn't call endpoint"));
|
.catch(err => ("couldn't call endpoint"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should return zeroes if userid does not exist', (done: Done) => {
|
||||||
|
fetch(getbaseURL() + '/api/userInfo?userID=getuserinfo_null')
|
||||||
|
.then(async res => {
|
||||||
|
const data = await res.json();
|
||||||
|
for (var value in data) {
|
||||||
|
if (data[value] === null && value !== "lastSegmentID") {
|
||||||
|
done(`returned null for ${value}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done(); // pass
|
||||||
|
})
|
||||||
|
.catch(err => ("couldn't call endpoint"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user