diff options
Diffstat (limited to 'challenge-228/steven-wilson/javascript/test')
| -rw-r--r-- | challenge-228/steven-wilson/javascript/test/index.html | 27 | ||||
| -rw-r--r-- | challenge-228/steven-wilson/javascript/test/tests.js | 30 |
2 files changed, 57 insertions, 0 deletions
diff --git a/challenge-228/steven-wilson/javascript/test/index.html b/challenge-228/steven-wilson/javascript/test/index.html new file mode 100644 index 0000000000..322f2615f3 --- /dev/null +++ b/challenge-228/steven-wilson/javascript/test/index.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <title>Mocha Tests</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" /> + <script src="https://unpkg.com/mocha/mocha.js"></script> + <script class="mocha-init"> + mocha.setup('bdd'); + </script> + <script src="https://unpkg.com/chai/chai.js"></script> + <script> + // make assert global + let assert = chai.assert; + </script> + </head> + <body> + <script src="../ch-01.js"></script> + <script src="../ch-02.js"></script> + <script src="tests.js"></script> + <div id="mocha"></div> + <script class="mocha-exec"> + mocha.run(); + </script> + </body> +</html> diff --git a/challenge-228/steven-wilson/javascript/test/tests.js b/challenge-228/steven-wilson/javascript/test/tests.js new file mode 100644 index 0000000000..21eddb69df --- /dev/null +++ b/challenge-228/steven-wilson/javascript/test/tests.js @@ -0,0 +1,30 @@ +describe("Challenge 228 task 1: sumUnique()", function() { + + it("2 unique elements", function() { + assert.equal( sumUnique([2, 1, 3, 2]), 4); + }); + + it("zero unique elements", function() { + assert.equal( sumUnique([1, 1, 1, 1]), 0); + }); + + it("all elements unique", function() { + assert.equal( sumUnique([2, 1, 3, 4]), 10); + }); +}); + + +describe("Challenge 228 task 2: emptyArray()", function() { + + it("array out of order", function() { + assert.equal( emptyArray([3, 4, 2]), 5); + }); + + it("array accending order", function() { + assert.equal( emptyArray([1, 2, 3]), 3); + }); + + it("array empty", function() { + assert.equal( emptyArray([]), 0); + }); +}); |
