Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Tiniest JavaScript unit testing library
=======================================

This is an in-browser JavaScript library I've been using for years. It's so small and simple that it never occured to me to open source it until I saw all the overly complicated alternatives that are out there.
This is an in-browser JavaScript library I've been using for years. It's so small and simple that it never occurred to me to open source it until I saw all the overly complicated alternatives that are out there.

If you're looking for a JavaScript library full of features or install guides that say things like `grunt`, `npm` or `bower`, you've come to the wrong place. Sorry, this probably isn't for you. Move along now.

Expand Down
19 changes: 16 additions & 3 deletions example/adder-test.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>jstinytest &mdash; Adder example</title>
</head>

<body>

<script src="../tinytest.js"></script>
<script src="adder.js"></script>
<script>
tests({

'adds numbers': function() {
eq(6, add(2, 4));
eq(6.6, add(2.6, 4));
assertEquals(6, add(2, 4));
assertEquals(6.6, add(2.6, 4));
},

'subtracts numbers': function() {
eq(-2, add(2, -4));
assertEquals(-2, add(2, -4));
},

});
</script>

</body>
</html>
5 changes: 3 additions & 2 deletions tinytest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* -Joe Walnes
* MIT License. See https://github.com/joewalnes/jstinytest/
*/
"use strict";
const TinyTest = {

run: function(tests) {
Expand Down Expand Up @@ -71,13 +72,13 @@ const TinyTest = {

assertEquals: function(expected, actual) {
if (expected != actual) {
throw new Error('assertEquals() "' + expected + '" != "' + actual + '"');
throw new Error(`assertEquals() "${expected}" != "${actual}"`);
}
},

assertStrictEquals: function(expected, actual) {
if (expected !== actual) {
throw new Error('assertStrictEquals() "' + expected + '" !== "' + actual + '"');
throw new Error(`assertStrictEquals() "${expected}" !== "${actual}"`);
}
},

Expand Down