-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
85 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<title>Test It Spec</title> | ||
<style> | ||
#summary {font-size: 2rem; text-transform: uppercase;} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="summary"></div> | ||
<div id="errors"></div> | ||
<script type="module" src="./runner.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
function spec(test) { | ||
// npm run test | ||
if(!test) { | ||
try { | ||
var test = require("../dist/testit.umd.js"); | ||
} catch(e) {}; | ||
} | ||
import test from "../src/testit.js"; | ||
|
||
return { | ||
"'like' should do truthy evaluation via ==": function() { | ||
test.expects(1).to.be.like('1'); | ||
test.expects("1").to.be.like(1); | ||
test.expects(1).to.be.ok(); | ||
}, | ||
"'equal' should do === evaluation exist": function() { | ||
test.expects(1).to.equal(1); | ||
test.expects('hello').to.equal('hello'); | ||
}, | ||
"you should be able to 'pass' a test": function() { | ||
test.expects().to.pass(); | ||
}, | ||
"you should be able to fail' a test too": function() { | ||
try { | ||
test.expects().to.fail(); | ||
} catch(e) { | ||
test.expects().to.pass(); | ||
} | ||
}, | ||
"you should be able to test if something 'exists'": function() { | ||
test.expects({}).to.exist(); | ||
test.expects({}).to.be.ok(); | ||
test.expects({}).to.be.a('object'); | ||
}, | ||
"should be able to check types": function() { | ||
test.expects(123).to.be.a('number'); | ||
test.expects([]).to.be.an('array'); | ||
test.expects({}).to.be.a('object'); | ||
test.expects(true).to.be.a('boolean'); | ||
test.expects(false).to.be.a('boolean'); | ||
test.expects(undefined).to.be.a('undefined'); | ||
export default test.it({ | ||
"'like' should do truthy evaluation via ==": function () { | ||
test.assert(1 == '1'); | ||
test.assert(1); | ||
}, | ||
"'equal' should do === evaluation exist": function () { | ||
test.assert(1 === 1); | ||
test.assert('hello' === 'hello'); | ||
}, | ||
"you should be able to 'pass' a test": function () { | ||
test.assert(1); | ||
}, | ||
"you should be able to fail' a test too": function () { | ||
try { | ||
test.assert(0); | ||
} catch (e) { | ||
} | ||
}; | ||
} | ||
}, | ||
"you should be able to test if something 'exists'": function () { | ||
test.assert({}); | ||
test.assert(typeof ({}) === 'object'); | ||
}, | ||
"should be able to check types": function () { | ||
|
||
test.assert(Array.isArray([])); | ||
test.assert(typeof (123) === 'number'); | ||
|
||
test.assert(typeof ({}) === 'object'); | ||
test.assert(typeof (true) === 'boolean'); | ||
test.assert(typeof (false) === 'boolean'); | ||
test.assert(typeof (undefined) === 'undefined'); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import spec from "./index.spec.js"; | ||
|
||
spec.run(false, function (r) { | ||
let errors = []; | ||
|
||
document.body.style.backgroundColor = ( | ||
r.fail.length ? "#ff9999" : "#99ff99" | ||
); | ||
|
||
r.pass.forEach((p) => errors.push(`<br>${p}`)); | ||
r.fail.forEach((f) => errors.push(`<br><b>${f}</b>`)); | ||
|
||
document.querySelector('#errors').innerHTML = errors; | ||
document.querySelector('#summary').innerHTML = `| tests: ${r.pass.length + r.fail.length} | pass: ${r.pass.length} | fail: ${r.fail.length} |`; | ||
}); |