Starting a mega simple testing suite

This commit is contained in:
shockrah 2021-02-11 16:16:50 -08:00
parent 90563b3214
commit 23c732390d
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,21 @@
class AssertionError extends Error {
constructor(msg) {
super(msg)
this.name = 'AssertionError'
}
}
/*
* @left left expression result to evaluate
* @right left expression result to evaluate
*
* @returns void on success
* @throws AssertionError on failure to be equal
*/
exports.eq = function(left, right) {
if(left != right) {
const msg = `${left} != ${right}`
throw new AssertionError(msg)
}
}

View File

@ -0,0 +1,15 @@
const assert = require('./assert.js');
const request = require('../src/request.js');
const response = require('../src/response.js');
(async () => {
try {
const result = await request.Request('get', 'localhost', 4536, '/channels/list', {}, null)
assert.eq(result.status_code, 400)
} catch (err) {
console.log(err)
}
})();