From 420577517c250e889eac9a5f517966c80f3737c7 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Thu, 1 Nov 2018 04:28:19 +0000 Subject: [PATCH] move todo-list examples from ./examples/todo-list/ to ./lib for https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example/issues/5 --- README.md | 2 +- examples/counter-basic-impure/index.html | 23 ---- examples/counter-basic-test/counter.js | 62 ---------- examples/counter-basic-test/index.html | 33 ----- examples/counter-basic-test/test.js | 47 ------- examples/counter-basic/index.html | 116 ------------------ examples/counter-reset-keyboard/counter.js | 50 -------- examples/counter-reset-keyboard/index.html | 24 ---- examples/counter-reset-keyboard/test.js | 71 ----------- examples/counter-reset/counter.js | 88 ------------- examples/counter-reset/index.html | 33 ----- examples/counter-reset/test.js | 71 ----------- .../multiple-counters-instances/index.html | 52 -------- examples/multiple-counters/counter.js | 89 -------------- examples/multiple-counters/index.html | 29 ----- examples/style.css | 41 ------- examples/todo-list/test.js | 74 ----------- {examples/todo-list => lib}/elmish.js | 0 {examples/todo-list => lib}/favicon.ico | Bin {examples/todo-list => lib}/index.html | 0 {examples/multiple-counters => lib}/test.js | 0 {examples/todo-list => lib}/todo-app.js | 0 {examples/todo-list => lib}/todo.html | 0 {examples/todo-list => lib}/todomvc-app.css | 0 .../todo-list => lib}/todomvc-common-base.css | 0 25 files changed, 1 insertion(+), 904 deletions(-) delete mode 100644 examples/counter-basic-impure/index.html delete mode 100644 examples/counter-basic-test/counter.js delete mode 100644 examples/counter-basic-test/index.html delete mode 100644 examples/counter-basic-test/test.js delete mode 100644 examples/counter-basic/index.html delete mode 100644 examples/counter-reset-keyboard/counter.js delete mode 100644 examples/counter-reset-keyboard/index.html delete mode 100644 examples/counter-reset-keyboard/test.js delete mode 100644 examples/counter-reset/counter.js delete mode 100644 examples/counter-reset/index.html delete mode 100644 examples/counter-reset/test.js delete mode 100644 examples/multiple-counters-instances/index.html delete mode 100644 examples/multiple-counters/counter.js delete mode 100644 examples/multiple-counters/index.html delete mode 100644 examples/style.css delete mode 100644 examples/todo-list/test.js rename {examples/todo-list => lib}/elmish.js (100%) rename {examples/todo-list => lib}/favicon.ico (100%) rename {examples/todo-list => lib}/index.html (100%) rename {examples/multiple-counters => lib}/test.js (100%) rename {examples/todo-list => lib}/todo-app.js (100%) rename {examples/todo-list => lib}/todo.html (100%) rename {examples/todo-list => lib}/todomvc-app.css (100%) rename {examples/todo-list => lib}/todomvc-common-base.css (100%) diff --git a/README.md b/README.md index b02a8ba..f74d6dc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Learn Elm Architecture in _Plain_ JavaScript +# TodoMVC Complete TDD Example in Vanilla JavaScript using Elm Architecture A step-by-step example/how-to for building TodoMVC from scratch in "plain" JavaScript (no frameworks!) diff --git a/examples/counter-basic-impure/index.html b/examples/counter-basic-impure/index.html deleted file mode 100644 index 540cd2e..0000000 --- a/examples/counter-basic-impure/index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - IMPURE Counter Example (DON'T DO THIS!!) - - - - - - -
0
- - - - diff --git a/examples/counter-basic-test/counter.js b/examples/counter-basic-test/counter.js deleted file mode 100644 index b8f635c..0000000 --- a/examples/counter-basic-test/counter.js +++ /dev/null @@ -1,62 +0,0 @@ -// Define the Component's Actions: -var Inc = 'inc'; // increment the counter -var Dec = 'dec'; // decrement the counter - -function update(model, action) { // Update function takes the current state - switch(action) { // and an action (String) runs a switch - case Inc: return model + 1; // add 1 to the model - case Dec: return model - 1; // subtract 1 from model - default: return model; // if no action, return curent state. - } // (default action always returns current) -} - -function view(signal, model, root) { - empty(root); // clear root element before - return [ // Store DOM nodes in an array - button('+', signal, Inc), // then iterate to append them - div('count', model), // avoids repetition. - button('-', signal, Dec) - ].forEach(function(el){ root.appendChild(el) }); // forEach is ES5 so IE9+ -} // yes, for loop is "faster" than forEach, but readability trumps "perf" here! - -// Mount Function receives all MUV and mounts the app in the "root" DOM Element -function mount(model, update, view, root_element_id) { - var root = document.getElementById(root_element_id); // root DOM element - function signal(action) { // signal function takes action - return function callback() { // and returns callback - model = update(model, action); // update model according to action - view(signal, model, root); // subsequent re-rendering - }; - }; - view(signal, model, root); // render initial model (once) -} - -// The following are "Helper" Functions which each "Do ONLY One Thing" and are -// used in the "View" function to render the Model (State) to the Browser DOM: - -// empty the contents of a given DOM element "node" (before re-rendering) -function empty(node) { - while (node.firstChild) { - node.removeChild(node.firstChild); - } -} // Inspired by: stackoverflow.com/a/3955238/1148249 - -function button(text, signal, action) { - var button = document.createElement('button'); - var text = document.createTextNode(text); // human-readable button text - button.appendChild(text); // text goes *inside* not attrib - button.className = action; // use action as CSS class - button.onclick = signal(action); // onclick tells how to process - return button; // return the DOM node(s) -} // how to create a button in JavaScript: stackoverflow.com/a/8650996/1148249 - -function div(divid, text) { - var div = document.createElement('div'); - div.id = divid; - div.className = divid; - if(text !== undefined) { // if text is passed in render it in a "Text Node" - var txt = document.createTextNode(text); - div.appendChild(txt); - } - return div; -} diff --git a/examples/counter-basic-test/index.html b/examples/counter-basic-test/index.html deleted file mode 100644 index 8cd064f..0000000 --- a/examples/counter-basic-test/index.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - Elm Architecture in JS - Counter Tests - - - - - -
- - - - -
-
- - - - - - - - - diff --git a/examples/counter-basic-test/test.js b/examples/counter-basic-test/test.js deleted file mode 100644 index db6dd13..0000000 --- a/examples/counter-basic-test/test.js +++ /dev/null @@ -1,47 +0,0 @@ -var id = 'test-app'; - -test('Test Update update(0) returns 0 (current state)', function(assert) { - var result = update(0); - assert.equal(result, 0); -}); - -test('Test Update increment: update(1, "inc") returns 2', function(assert) { - var result = update(1, "inc"); - assert.equal(result, 2); -}); - -test('Test Update decrement: update(3, "dec") returns 2', function(assert) { - var result = update(1, "dec"); - assert.equal(result, 0); -}); - -test('Test negative state: update(-9, "inc") returns -8', function(assert) { - var result = update(-9, "inc"); - assert.equal(result, -8); -}); - -test('mount({model: 9, update: update, view: view}, "' - + id +'") sets initial state to 9', function(assert) { - mount(9, update, view, id); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 9); -}); - -test('empty("test-app") should clear DOM in root node', function(assert) { - empty(document.getElementById(id)); - mount(7, update, view, id); - empty(document.getElementById(id)); - var result = document.getElementById(id).innerHtml - assert.equal(result, undefined); -}); - -test('click on "+" button to re-render state (increment model by 1)', -function(assert) { - mount(7, update, view, id); - document.getElementById(id).getElementsByClassName('inc')[0].click(); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 8); // model was incremented successfully - empty(document.getElementById(id)); -}); diff --git a/examples/counter-basic/index.html b/examples/counter-basic/index.html deleted file mode 100644 index 708a430..0000000 --- a/examples/counter-basic/index.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - Elm Architecture in Pure JavaScript - Simple Counter Example - - - - - - -
- - - -
-
- - - - - - - - -
click me
- - - - diff --git a/examples/counter-reset-keyboard/counter.js b/examples/counter-reset-keyboard/counter.js deleted file mode 100644 index 48c9924..0000000 --- a/examples/counter-reset-keyboard/counter.js +++ /dev/null @@ -1,50 +0,0 @@ -/* if require is available, it means we are in Node.js Land i.e. testing! - in the broweser, the "elmish" DOM functions are loaded in a - - -
- - - - - - diff --git a/examples/counter-reset-keyboard/test.js b/examples/counter-reset-keyboard/test.js deleted file mode 100644 index 0a525c5..0000000 --- a/examples/counter-reset-keyboard/test.js +++ /dev/null @@ -1,71 +0,0 @@ -var id = 'test-app'; - -test('Test Update update(0) returns 0 (current state)', function(assert) { - var result = update('unrecognised', 0); - assert.equal(result, 0); -}); - -test('Test Update increment: update(1, "inc") returns 2', function(assert) { - var result = update("inc", 1,); - assert.equal(result, 2); -}); - -test('Test Update decrement: update("dec", 3) returns 2', function(assert) { - var result = update("dec", 3); - assert.equal(result, 2); -}); - -test('Test negative state: update("inc", -9) returns -8', function(assert) { - var result = update("inc", -9, ); - assert.equal(result, -8); -}); - -test('mount({model: 7, update: update, view: view}, "' - + id +'") sets initial state to 7', function(assert) { - mount(7, update, view, id); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 7); -}); - -test('empty("test-app") should clear DOM in root node', function(assert) { - empty(document.getElementById(id)); - mount(7, update, view, id); - empty(document.getElementById(id)); - var result = document.getElementById(id).innerHtml - assert.equal(result, undefined); -}); - -test('click on "+" button to re-render state (increment model by 1)', -function(assert) { - document.body.appendChild(div(id)); - mount(7, update, view, id); - document.getElementById(id).getElementsByClassName('inc')[0].click(); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 8); // model was incremented successfully - empty(document.getElementById(id)); // clean up after tests -}); - -// Reset Functionality - -test('Test reset counter when model/state is 6 returns 0', function(assert) { - var result = update("reset", 6); - assert.equal(result, 0); -}); - -test('reset button should be present on page', function(assert) { - var reset = document.getElementsByClassName('reset'); - assert.equal(reset.length, 1); -}); - -test('Click reset button resets state to 0', function(assert) { - mount(7, update, view, id); - var root = document.getElementById(id); - assert.equal(root.getElementsByClassName('count')[0].textContent, 7); - var btn = root.getElementsByClassName("reset")[0]; // click reset button - btn.click(); // Click the Reset button! - var state = root.getElementsByClassName('count')[0].textContent; - assert.equal(state, 0); // state was successfully reset to 0! - empty(root); // clean up after tests -}); diff --git a/examples/counter-reset/counter.js b/examples/counter-reset/counter.js deleted file mode 100644 index f791063..0000000 --- a/examples/counter-reset/counter.js +++ /dev/null @@ -1,88 +0,0 @@ -// Define the Component's Actions: -var Inc = 'inc'; // increment the counter -var Dec = 'dec'; // decrement the counter -var Res = 'reset'; // reset counter: git.io/v9KJk - -function update (action, model) { // Update function takes the current state - switch(action) { // and an action (String) runs a switch - case Inc: return model + 1; // add 1 to the model - case Dec: return model - 1; // subtract 1 from model - case Res: return 0; // reset state to 0 (Zero) git.io/v9KJk - default: return model; // if no action, return curent state. - } // (default action always returns current) -} - -function view(model, signal) { - return container([ // Store DOM nodes in an array - button('+', signal, Inc), // then iterate to append them - div('count', model), // create div with stat as text - button('-', signal, Dec), // decrement counter - button('Reset', signal, Res) // reset counter - ]); // forEach is ES5 so IE9+ -} // yes, for loop is "faster" than forEach, but readability trumps "perf" here! - -// Mount Function receives all MUV and mounts the app in the "root" DOM Element -function mount(model, update, view, root_element_id) { - var root = document.getElementById(root_element_id); // root DOM element - function signal(action) { // signal function takes action - return function callback() { // and returns callback - model = update(action, model); // update model according to action - empty(root); - root.appendChild(view(model, signal)); // subsequent re-rendering - }; - }; - root.appendChild(view(model, signal)); // render initial model (once) -} - -// The following are "Helper" Functions which each "Do ONLY One Thing" and are -// used in the "View" function to render the Model (State) to the Browser DOM: - -// empty the contents of a given DOM element "node" (before re-rendering) -function empty(node) { - while (node.firstChild) { - node.removeChild(node.firstChild); - } -} // Inspired by: stackoverflow.com/a/3955238/1148249 - -function button(text, signal, action) { - var button = document.createElement('button'); - var text = document.createTextNode(text); // human-readable button text - button.appendChild(text); // text goes *inside* not attrib - button.className = action; // use action as CSS class - button.id = action; - // console.log(signal, ' action:', action) - button.onclick = signal(action); // onclick tells how to process - return button; // return the DOM node(s) -} // how to create a button in JavaScript: stackoverflow.com/a/8650996/1148249 - -function div(divid, text) { - var div = document.createElement('div'); - div.id = divid; - div.className = divid; - if(text !== undefined) { // if text is passed in render it in a "Text Node" - var txt = document.createTextNode(text); - div.appendChild(txt); - } - return div; -} - -// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section -function container(elements) { - var con = document.createElement('section'); - con.className = 'counter'; - elements.forEach(function(el) { con.appendChild(el) }); - return con; -} - -/* The code block below ONLY Applies to tests run using Node.js */ -/* istanbul ignore else */ -if (typeof module !== 'undefined' && module.exports) { - module.exports = { - view: view, - mount: mount, - update: update, - div: div, - button: button, - empty: empty, - } -} diff --git a/examples/counter-reset/index.html b/examples/counter-reset/index.html deleted file mode 100644 index e6ecb50..0000000 --- a/examples/counter-reset/index.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - Elm Architecture in JS - Counter Reset - - - - - -
- - - - -
-
- - - - - - - - - diff --git a/examples/counter-reset/test.js b/examples/counter-reset/test.js deleted file mode 100644 index 0a525c5..0000000 --- a/examples/counter-reset/test.js +++ /dev/null @@ -1,71 +0,0 @@ -var id = 'test-app'; - -test('Test Update update(0) returns 0 (current state)', function(assert) { - var result = update('unrecognised', 0); - assert.equal(result, 0); -}); - -test('Test Update increment: update(1, "inc") returns 2', function(assert) { - var result = update("inc", 1,); - assert.equal(result, 2); -}); - -test('Test Update decrement: update("dec", 3) returns 2', function(assert) { - var result = update("dec", 3); - assert.equal(result, 2); -}); - -test('Test negative state: update("inc", -9) returns -8', function(assert) { - var result = update("inc", -9, ); - assert.equal(result, -8); -}); - -test('mount({model: 7, update: update, view: view}, "' - + id +'") sets initial state to 7', function(assert) { - mount(7, update, view, id); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 7); -}); - -test('empty("test-app") should clear DOM in root node', function(assert) { - empty(document.getElementById(id)); - mount(7, update, view, id); - empty(document.getElementById(id)); - var result = document.getElementById(id).innerHtml - assert.equal(result, undefined); -}); - -test('click on "+" button to re-render state (increment model by 1)', -function(assert) { - document.body.appendChild(div(id)); - mount(7, update, view, id); - document.getElementById(id).getElementsByClassName('inc')[0].click(); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 8); // model was incremented successfully - empty(document.getElementById(id)); // clean up after tests -}); - -// Reset Functionality - -test('Test reset counter when model/state is 6 returns 0', function(assert) { - var result = update("reset", 6); - assert.equal(result, 0); -}); - -test('reset button should be present on page', function(assert) { - var reset = document.getElementsByClassName('reset'); - assert.equal(reset.length, 1); -}); - -test('Click reset button resets state to 0', function(assert) { - mount(7, update, view, id); - var root = document.getElementById(id); - assert.equal(root.getElementsByClassName('count')[0].textContent, 7); - var btn = root.getElementsByClassName("reset")[0]; // click reset button - btn.click(); // Click the Reset button! - var state = root.getElementsByClassName('count')[0].textContent; - assert.equal(state, 0); // state was successfully reset to 0! - empty(root); // clean up after tests -}); diff --git a/examples/multiple-counters-instances/index.html b/examples/multiple-counters-instances/index.html deleted file mode 100644 index 54a7808..0000000 --- a/examples/multiple-counters-instances/index.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - Elm Architecture in JS - Counter Reset - - - - -
-
-
- - - - - - diff --git a/examples/multiple-counters/counter.js b/examples/multiple-counters/counter.js deleted file mode 100644 index a28d87c..0000000 --- a/examples/multiple-counters/counter.js +++ /dev/null @@ -1,89 +0,0 @@ -// Define the Component's Actions: -var Inc = 'inc'; // increment the counter -var Dec = 'dec'; // decrement the counter -var Res = 'reset'; // reset counter: git.io/v9KJk - -function update(model, action) { // Update function takes the current state - var parts = action ? action.split('-') : []; // e.g: inc-0 where 0 is the counter "id" - var act = parts[0]; - var index = parts[1] || 0; - var new_model = JSON.parse(JSON.stringify(model)) // "clone" the model - switch(act) { // and an action (String) runs a switch - case Inc: - new_model.counters[index] = model.counters[index] + 1; - break; - case Dec: - new_model.counters[index] = model.counters[index] - 1; - break; - case Res: // use ES6 Array.fill to create a new array with values set to 0: - new_model.counters[index] = 0; - break; - default: return model; // if action not defined, return curent state. - } - return new_model; -} - -function view(signal, model, root) { - empty(root); // clear root element before re-rendering the App (DOM). - model.counters.map(function(counter, index) { - return container(index, [ // wrap DOM nodes in an "container" - button('+', signal, Inc + '-' + index), // append index to action - div('count', counter), // create div w/ count as text - button('-', signal, Dec + '-' + index), // decrement counter - button('Reset', signal, Res + '-' + index) // reset counter - ]); - }).forEach(function (el) { root.appendChild(el) }); // forEach is ES5 so IE9+ -} - -// Mount Function receives all MUV and mounts the app in the "root" DOM Element -function mount(model, update, view, root_element_id) { - var root = document.getElementById(root_element_id); // root DOM element - function signal(action) { // signal function takes action - return function callback() { // and returns callback - model = update(model, action); // update model according to action - view(signal, model, root); // subsequent re-rendering - }; - }; - view(signal, model, root); // render initial model (once) -} - -// The following are "Helper" Functions which each "Do ONLY One Thing" and are -// used in the "View" function to render the Model (State) to the Browser DOM: - -// empty the contents of a given DOM element "node" (before re-rendering) -function empty(node) { - while (node.firstChild) { - node.removeChild(node.firstChild); - } -} // Inspired by: stackoverflow.com/a/3955238/1148249 - -// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section -function container(index, elements) { - var con = document.createElement('section'); - con.id = index; - con.className = 'counter'; - elements.forEach(function(el) { con.appendChild(el) }); - return con; -} - -function button(text, signal, action) { - var button = document.createElement('button'); - var text = document.createTextNode(text); // human-readable button text - button.appendChild(text); // text goes *inside* not attrib - button.className = action.split('-')[0]; // use action as CSS class - button.id = action; - // console.log(signal, ' action:', action) - button.onclick = signal(action); // onclick tells how to process - return button; // return the DOM node(s) -} // how to create a button in JavaScript: stackoverflow.com/a/8650996/1148249 - -function div(divid, text) { - var div = document.createElement('div'); - div.id = divid; - div.className = divid; - if(text !== undefined) { // if text is passed in render it in a "Text Node" - var txt = document.createTextNode(text); - div.appendChild(txt); - } - return div; -} diff --git a/examples/multiple-counters/index.html b/examples/multiple-counters/index.html deleted file mode 100644 index 3d78a4d..0000000 --- a/examples/multiple-counters/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Elm Architecture in JS - Counter Reset - - - - - -
- - - -
-
- - - - - - - - - diff --git a/examples/style.css b/examples/style.css deleted file mode 100644 index 8ddfa8d..0000000 --- a/examples/style.css +++ /dev/null @@ -1,41 +0,0 @@ -body{ - font-family: Courier, "Lucida Console", monospace; - font-size: 4em; - text-align: center; - background-color: white; -} -button { - font-size: 0.5em; color:white; border:5px solid; border-radius: 0.5em; - padding:0.1em; margin: 0.2em auto; - display: block; width: 20%; -} -.inc { - background-color: #2ecc71; border-color: #27ae60; -} -.dec { - background-color: #e74c3c; border-color: #c0392b; -} -.reset { - background-color: #f39c12; border-color: #e67e22; -} - -#qunit { - padding-top: 0.5em; - width: 100%; - clear: both; -} - -#qunit-header { /* just cause the default style makes the header HUGE!! */ - font-size: 0.4em !important; -} - -/* specific to multiple counters */ -section { - background-color: white; - float: left; - padding-right: 1%; - width: 32%; -} -section button { - width: 100%; -} diff --git a/examples/todo-list/test.js b/examples/todo-list/test.js deleted file mode 100644 index 7768095..0000000 --- a/examples/todo-list/test.js +++ /dev/null @@ -1,74 +0,0 @@ -var id = 'test-app'; - -test('update({counters:[0]}) returns {counters:[0]} (current state unmodified)', - function(assert) { - var result = update({counters:[0]}); - assert.equal(result.counters[0], 0); -}); - -test('Test Update increment: update(1, "inc") returns 2', function(assert) { - var result = update({counters: [1] }, "inc"); - console.log('result', result); - assert.equal(result.counters[0], 2); -}); - - -test('Test Update decrement: update(1, "dec") returns 0', function(assert) { - var result = update({counters: [1] }, "dec"); - assert.equal(result.counters[0], 0); -}); - -test('Test negative state: update(-9, "inc") returns -8', function(assert) { - var result = update({counters: [-9] }, "inc"); - assert.equal(result.counters[0], -8); -}); - -test('mount({model: 7, update: update, view: view}, "' - + id +'") sets initial state to 7', function(assert) { - mount({counters:[7]}, update, view, id); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 7); -}); - -test('empty("test-app") should clear DOM in root node', function(assert) { - empty(document.getElementById(id)); - mount({counters:[7]}, update, view, id); - empty(document.getElementById(id)); - var result = document.getElementById(id).innerHtml - assert.equal(result, undefined); -}); - -test('click on "+" button to re-render state (increment model by 1)', -function(assert) { - document.body.appendChild(div(id)); - mount({counters:[7]}, update, view, id); - document.getElementById(id).getElementsByClassName('inc')[0].click(); - var state = document.getElementById(id) - .getElementsByClassName('count')[0].textContent; - assert.equal(state, 8); // model was incremented successfully - empty(document.getElementById(id)); // clean up after tests -}); - -// Reset Functionality - -test('Test reset counter when model/state is 6 returns 0', function(assert) { - var result = update({counters:[7]}, "reset"); - assert.equal(result.counters[0], 0); -}); - -test('reset button should be present on page', function(assert) { - var reset = document.getElementsByClassName('reset'); - assert.equal(reset.length, 3); -}); - -test('Click reset button resets state to 0', function(assert) { - mount({counters:[7]}, update, view, id); - var root = document.getElementById(id); - assert.equal(root.getElementsByClassName('count')[0].textContent, 7); - var btn = root.getElementsByClassName("reset")[0]; // click reset button - btn.click(); // Click the Reset button! - var state = root.getElementsByClassName('count')[0].textContent; - assert.equal(state, 0); // state was successfully reset to 0! - empty(root); // clean up after tests -}); diff --git a/examples/todo-list/elmish.js b/lib/elmish.js similarity index 100% rename from examples/todo-list/elmish.js rename to lib/elmish.js diff --git a/examples/todo-list/favicon.ico b/lib/favicon.ico similarity index 100% rename from examples/todo-list/favicon.ico rename to lib/favicon.ico diff --git a/examples/todo-list/index.html b/lib/index.html similarity index 100% rename from examples/todo-list/index.html rename to lib/index.html diff --git a/examples/multiple-counters/test.js b/lib/test.js similarity index 100% rename from examples/multiple-counters/test.js rename to lib/test.js diff --git a/examples/todo-list/todo-app.js b/lib/todo-app.js similarity index 100% rename from examples/todo-list/todo-app.js rename to lib/todo-app.js diff --git a/examples/todo-list/todo.html b/lib/todo.html similarity index 100% rename from examples/todo-list/todo.html rename to lib/todo.html diff --git a/examples/todo-list/todomvc-app.css b/lib/todomvc-app.css similarity index 100% rename from examples/todo-list/todomvc-app.css rename to lib/todomvc-app.css diff --git a/examples/todo-list/todomvc-common-base.css b/lib/todomvc-common-base.css similarity index 100% rename from examples/todo-list/todomvc-common-base.css rename to lib/todomvc-common-base.css