replace if tests with assert

This commit is contained in:
Michael C
2021-07-07 03:47:08 -04:00
parent e94d1d4bae
commit 178ed1e5af
22 changed files with 1344 additions and 2041 deletions

View File

@@ -2,6 +2,7 @@ import fetch from 'node-fetch';
import * as utils from '../utils';
import { getHash } from '../../src/utils/getHash';
import { db } from '../../src/databases/databases';
import assert from 'assert';
describe('unBan', () => {
before(async () => {
@@ -31,19 +32,10 @@ describe('unBan', () => {
},
})
.then(async res => {
if (res.status === 200) {
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-0', 'testMan-unBan', 1]);
if (result.length !== 0) {
console.log(result);
done("Expected 0 banned entrys in db, got " + result.length);
} else {
done();
}
} else {
const body = await res.text();
console.log(body);
done("Status code was " + res.status);
}
assert.strictEqual(res.status, 200);
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-0', 'testMan-unBan', 1]);
assert.strictEqual(result.length, 0);
done();
})
.catch(err => done(err));
});
@@ -56,19 +48,10 @@ describe('unBan', () => {
},
})
.then(async res => {
if (res.status === 200) {
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-1', 'testWoman-unBan', 1]);
if (result.length !== 1) {
console.log(result);
done("Expected 1 banned entry1 in db, got " + result.length);
} else {
done();
}
} else {
const body = await res.text();
console.log(body);
done("Status code was " + res.status);
}
assert.strictEqual(res.status, 200);
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "videoID" = ? AND "userID" = ? AND "shadowHidden" = ?', ['unBan-videoID-1', 'testWoman-unBan', 1]);
assert.strictEqual(result.length, 1);
done();
})
.catch(err => done(err));
});
@@ -81,19 +64,10 @@ describe('unBan', () => {
},
})
.then(async res => {
if (res.status === 200) {
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "userID" = ? AND "shadowHidden" = ?', ['testEntity-unBan', 1]);
if (result.length !== 1) {
console.log(result);
done("Expected 1 banned entry1 in db, got " + result.length);
} else {
done();
}
} else {
const body = await res.text();
console.log(body);
done("Status code was " + res.status);
}
assert.strictEqual(res.status, 200);
const result = await db.prepare('all', 'SELECT * FROM "sponsorTimes" WHERE "userID" = ? AND "shadowHidden" = ?', ['testEntity-unBan', 1]);
assert.strictEqual(result.length, 1);
done();
})
.catch(err => done(err));
});