Update tests to use promises

This commit is contained in:
Ajay Ramachandran
2021-03-01 21:37:35 -05:00
parent ff4af3786e
commit 46b42da5bd
19 changed files with 274 additions and 259 deletions

View File

@@ -7,7 +7,7 @@ describe('postVideoSponsorTime (Old submission method)', () => {
it('Should be able to submit a time (GET)', (done: Done) => {
fetch(getbaseURL()
+ "/api/postVideoSponsorTimes?videoID=dQw4w9WgXcQ&startTime=1&endTime=10&userID=test")
.then(res => {
.then(async res => {
if (res.status === 200) {
let row = await db.prepare('get', "SELECT startTime, endTime, category FROM sponsorTimes WHERE videoID = ?", ["dQw4w9WgXcQ"]);
if (row.startTime === 1 && row.endTime === 10 && row.category === "sponsor") {
@@ -30,7 +30,7 @@ describe('postVideoSponsorTime (Old submission method)', () => {
'Content-Type': 'application/json',
},
})
.then(res => {
.then(async res => {
if (res.status === 200) {
let row = await db.prepare('get', "SELECT startTime, endTime, category FROM sponsorTimes WHERE videoID = ?", ["dQw4w9WgXcE"]);
if (row.startTime === 1 && row.endTime === 11 && row.category === "sponsor") {
@@ -48,7 +48,7 @@ describe('postVideoSponsorTime (Old submission method)', () => {
it('Should return 400 for missing params', (done: Done) => {
fetch(getbaseURL()
+ "/api/postVideoSponsorTimes?startTime=1&endTime=10&userID=test")
.then(res => {
.then(async res => {
if (res.status === 400) done();
else done("Status code was: " + res.status);
})