Signup tentatively works
This commit is contained in:
27
_test/OrderedObject.test.js
Normal file
27
_test/OrderedObject.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import OrderedObject from "../server/db/model/OrderedObject.js"
|
||||
|
||||
window.testSuites.push(
|
||||
|
||||
class testOrderedObject {
|
||||
|
||||
async addShouldFailIfKeyIsDuplicate() {
|
||||
class Test extends OrderedObject {
|
||||
|
||||
}
|
||||
|
||||
let test = new Test()
|
||||
|
||||
test.add("1", {name: "hello"})
|
||||
|
||||
try {
|
||||
test.add("1", {name: "bye"})
|
||||
} catch(e){
|
||||
return
|
||||
}
|
||||
|
||||
return "Received no error!"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
)
|
||||
57
_test/test.js
Normal file
57
_test/test.js
Normal file
@@ -0,0 +1,57 @@
|
||||
let scriptToPaste = `
|
||||
<script type="module" src="./_test/test.js"></script>
|
||||
`;
|
||||
console.log("Tests initializing.")
|
||||
window.testSuites = [];
|
||||
|
||||
/* Server - DB */
|
||||
import ("./OrderedObject.test.js")
|
||||
|
||||
window.test = async function() {
|
||||
// window.testSuites.sort();
|
||||
window.alert = () => true;
|
||||
window.confirm = () => true;
|
||||
|
||||
console.clear();
|
||||
|
||||
let failed = 0;
|
||||
let success = 0;
|
||||
|
||||
var start = new Date();
|
||||
for(let j=0; j<window.testSuites.length; j++) {
|
||||
let testSuite = window.testSuites[j];
|
||||
console.log(`%c ➽ ${j+1} ${testSuite.name.replace("test", "")}`, 'color: #ffffff; font-size: 17px; padding-left: -20px; padding-top: 10px; padding-bottom: 10px; text-align: right;')
|
||||
let suite = new testSuite();
|
||||
let testNum = 0;
|
||||
let suiteContents = Object.getOwnPropertyNames(testSuite.prototype)
|
||||
for(let i=0; i<suiteContents.length; i++) {
|
||||
let test = suiteContents[i];
|
||||
if(typeof suite[test] === 'function' && test !== "constructor") {
|
||||
testNum++;
|
||||
let fail = await suite[test]();
|
||||
if(fail) {
|
||||
failed++;
|
||||
console.log(`%c ${testNum}. ${test}: ${fail}`, 'background: #222; color: rgb(254, 62, 43)');
|
||||
} else {
|
||||
success++;
|
||||
console.log(`%c ${testNum}. ${test}`, 'background: #222; color: #00FF00');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("")
|
||||
console.log("")
|
||||
let elapsed = new Date() - start;
|
||||
if(failed === 0) {
|
||||
console.log(`%cRan ${failed+success} tests in ${elapsed}ms`, 'background: #222; color: #00FF00');
|
||||
} else {
|
||||
console.log(`%cRan ${failed+success} tests in ${elapsed}ms`, 'background: #222; color: rgb(254, 62, 43)');
|
||||
}
|
||||
console.log(`%c ${success} passed`, 'background: #222; color: #00FF00');
|
||||
console.log(`%c ${failed} failed`, 'background: #222; color: rgb(254, 62, 43)');
|
||||
}
|
||||
|
||||
window.wait = ms => new Promise(res => setTimeout(res, ms));
|
||||
|
||||
window.__defineGetter__("test", test);
|
||||
Reference in New Issue
Block a user