Commit b4d50c05 authored by TasteBot's avatar TasteBot

update the build files for gh-pages [ci skip]

parent 5d415fdb
/*global define */ /*global define */
define({ define({
// Cujo uses OOCSS principles and thus separates theme (skin)
// from structure CSS.
theme: { module: 'css!theme/base.css' },
// The root node where all the views will be inserted // The root node where all the views will be inserted
root: { $ref: 'dom!todoapp' }, root: { $ref: 'dom!todoapp' },
......
#clear-completed {
transition: all .1s ease;
-webkit-transition: all .1s ease;
-moz-transition: all .1s ease;
-ms-transition: all .1s ease;
-o-transition: all .1s ease;
}
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
<link rel="stylesheet" href="node_modules/todomvc-app-css/index.css"> <link rel="stylesheet" href="node_modules/todomvc-app-css/index.css">
</head> </head>
<body> <body>
<section id="todoapp"> <section class="todoapp">
<header id="header"> <header class="header">
<h1>todos</h1> <h1>todos</h1>
<input id="new-todo" placeholder="What needs to be done?" autofocus> <input class="new-todo" placeholder="What needs to be done?" autofocus>
</header> </header>
<section id="main"> <section class="main">
<input id="toggle-all" type="checkbox"> <input class="toggle-all" type="checkbox">
<label for="toggle-all">Mark all as complete</label> <label for="toggle-all">Mark all as complete</label>
<ul id="todo-list"></ul> <ul class="todo-list"></ul>
</section> </section>
<footer id="footer"> <footer class="footer">
<span id="todo-count"></span> <span class="todo-count"></span>
<ul id="filters"> <ul class="filters">
<li> <li>
<a href="#/" class="selected">All</a> <a href="#/" class="selected">All</a>
</li> </li>
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
<a href="#/completed">Completed</a> <a href="#/completed">Completed</a>
</li> </li>
</ul> </ul>
<button id="clear-completed">Clear completed</button> <button class="clear-completed">Clear completed</button>
</footer> </footer>
</section> </section>
<footer id="info"> <footer class="info">
<p>Double-click to edit a todo</p> <p>Double-click to edit a todo</p>
<p>Created by <a href="http://twitter.com/oscargodson">Oscar Godson</a></p> <p>Created by <a href="http://twitter.com/oscargodson">Oscar Godson</a></p>
<p>Refactored by <a href="https://github.com/cburgmer">Christoph Burgmer</a></p> <p>Refactored by <a href="https://github.com/cburgmer">Christoph Burgmer</a></p>
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
this.ENTER_KEY = 13; this.ENTER_KEY = 13;
this.ESCAPE_KEY = 27; this.ESCAPE_KEY = 27;
this.$todoList = qs('#todo-list'); this.$todoList = qs('.todo-list');
this.$todoItemCounter = qs('#todo-count'); this.$todoItemCounter = qs('.todo-count');
this.$clearCompleted = qs('#clear-completed'); this.$clearCompleted = qs('.clear-completed');
this.$main = qs('#main'); this.$main = qs('.main');
this.$footer = qs('#footer'); this.$footer = qs('.footer');
this.$toggleAll = qs('#toggle-all'); this.$toggleAll = qs('.toggle-all');
this.$newTodo = qs('#new-todo'); this.$newTodo = qs('.new-todo');
} }
View.prototype._removeItem = function (id) { View.prototype._removeItem = function (id) {
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
}; };
View.prototype._setFilter = function (currentPage) { View.prototype._setFilter = function (currentPage) {
qs('#filters .selected').className = ''; qs('.filters .selected').className = '';
qs('#filters [href="#/' + currentPage + '"]').className = 'selected'; qs('.filters [href="#/' + currentPage + '"]').className = 'selected';
}; };
View.prototype._elementComplete = function (id, completed) { View.prototype._elementComplete = function (id, completed) {
......
...@@ -44,7 +44,7 @@ input[type="checkbox"] { ...@@ -44,7 +44,7 @@ input[type="checkbox"] {
display: none; display: none;
} }
#todoapp { .todoapp {
background: #fff; background: #fff;
margin: 130px 0 40px 0; margin: 130px 0 40px 0;
position: relative; position: relative;
...@@ -52,25 +52,25 @@ input[type="checkbox"] { ...@@ -52,25 +52,25 @@ input[type="checkbox"] {
0 25px 50px 0 rgba(0, 0, 0, 0.1); 0 25px 50px 0 rgba(0, 0, 0, 0.1);
} }
#todoapp input::-webkit-input-placeholder { .todoapp input::-webkit-input-placeholder {
font-style: italic; font-style: italic;
font-weight: 300; font-weight: 300;
color: #e6e6e6; color: #e6e6e6;
} }
#todoapp input::-moz-placeholder { .todoapp input::-moz-placeholder {
font-style: italic; font-style: italic;
font-weight: 300; font-weight: 300;
color: #e6e6e6; color: #e6e6e6;
} }
#todoapp input::input-placeholder { .todoapp input::input-placeholder {
font-style: italic; font-style: italic;
font-weight: 300; font-weight: 300;
color: #e6e6e6; color: #e6e6e6;
} }
#todoapp h1 { .todoapp h1 {
position: absolute; position: absolute;
top: -155px; top: -155px;
width: 100%; width: 100%;
...@@ -83,7 +83,7 @@ input[type="checkbox"] { ...@@ -83,7 +83,7 @@ input[type="checkbox"] {
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
} }
#new-todo, .new-todo,
.edit { .edit {
position: relative; position: relative;
margin: 0; margin: 0;
...@@ -104,14 +104,14 @@ input[type="checkbox"] { ...@@ -104,14 +104,14 @@ input[type="checkbox"] {
font-smoothing: antialiased; font-smoothing: antialiased;
} }
#new-todo { .new-todo {
padding: 16px 16px 16px 60px; padding: 16px 16px 16px 60px;
border: none; border: none;
background: rgba(0, 0, 0, 0.003); background: rgba(0, 0, 0, 0.003);
box-shadow: inset 0 -2px 1px rgba(0,0,0,0.03); box-shadow: inset 0 -2px 1px rgba(0,0,0,0.03);
} }
#main { .main {
position: relative; position: relative;
z-index: 2; z-index: 2;
border-top: 1px solid #e6e6e6; border-top: 1px solid #e6e6e6;
...@@ -121,7 +121,7 @@ label[for='toggle-all'] { ...@@ -121,7 +121,7 @@ label[for='toggle-all'] {
display: none; display: none;
} }
#toggle-all { .toggle-all {
position: absolute; position: absolute;
top: -55px; top: -55px;
left: -12px; left: -12px;
...@@ -131,50 +131,50 @@ label[for='toggle-all'] { ...@@ -131,50 +131,50 @@ label[for='toggle-all'] {
border: none; /* Mobile Safari */ border: none; /* Mobile Safari */
} }
#toggle-all:before { .toggle-all:before {
content: '❯'; content: '❯';
font-size: 22px; font-size: 22px;
color: #e6e6e6; color: #e6e6e6;
padding: 10px 27px 10px 27px; padding: 10px 27px 10px 27px;
} }
#toggle-all:checked:before { .toggle-all:checked:before {
color: #737373; color: #737373;
} }
#todo-list { .todo-list {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
#todo-list li { .todo-list li {
position: relative; position: relative;
font-size: 24px; font-size: 24px;
border-bottom: 1px solid #ededed; border-bottom: 1px solid #ededed;
} }
#todo-list li:last-child { .todo-list li:last-child {
border-bottom: none; border-bottom: none;
} }
#todo-list li.editing { .todo-list li.editing {
border-bottom: none; border-bottom: none;
padding: 0; padding: 0;
} }
#todo-list li.editing .edit { .todo-list li.editing .edit {
display: block; display: block;
width: 506px; width: 506px;
padding: 13px 17px 12px 17px; padding: 13px 17px 12px 17px;
margin: 0 0 0 43px; margin: 0 0 0 43px;
} }
#todo-list li.editing .view { .todo-list li.editing .view {
display: none; display: none;
} }
#todo-list li .toggle { .todo-list li .toggle {
text-align: center; text-align: center;
width: 40px; width: 40px;
/* auto, since non-WebKit browsers doesn't support input styling */ /* auto, since non-WebKit browsers doesn't support input styling */
...@@ -188,15 +188,15 @@ label[for='toggle-all'] { ...@@ -188,15 +188,15 @@ label[for='toggle-all'] {
appearance: none; appearance: none;
} }
#todo-list li .toggle:after { .todo-list li .toggle:after {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#ededed" stroke-width="3"/></svg>'); content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#ededed" stroke-width="3"/></svg>');
} }
#todo-list li .toggle:checked:after { .todo-list li .toggle:checked:after {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#bddad5" stroke-width="3"/><path fill="#5dc2af" d="M72 25L42 71 27 56l-4 4 20 20 34-52z"/></svg>'); content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="-10 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#bddad5" stroke-width="3"/><path fill="#5dc2af" d="M72 25L42 71 27 56l-4 4 20 20 34-52z"/></svg>');
} }
#todo-list li label { .todo-list li label {
white-space: pre; white-space: pre;
word-break: break-word; word-break: break-word;
padding: 15px 60px 15px 15px; padding: 15px 60px 15px 15px;
...@@ -206,12 +206,12 @@ label[for='toggle-all'] { ...@@ -206,12 +206,12 @@ label[for='toggle-all'] {
transition: color 0.4s; transition: color 0.4s;
} }
#todo-list li.completed label { .todo-list li.completed label {
color: #d9d9d9; color: #d9d9d9;
text-decoration: line-through; text-decoration: line-through;
} }
#todo-list li .destroy { .todo-list li .destroy {
display: none; display: none;
position: absolute; position: absolute;
top: 0; top: 0;
...@@ -226,27 +226,27 @@ label[for='toggle-all'] { ...@@ -226,27 +226,27 @@ label[for='toggle-all'] {
transition: color 0.2s ease-out; transition: color 0.2s ease-out;
} }
#todo-list li .destroy:hover { .todo-list li .destroy:hover {
color: #af5b5e; color: #af5b5e;
} }
#todo-list li .destroy:after { .todo-list li .destroy:after {
content: '×'; content: '×';
} }
#todo-list li:hover .destroy { .todo-list li:hover .destroy {
display: block; display: block;
} }
#todo-list li .edit { .todo-list li .edit {
display: none; display: none;
} }
#todo-list li.editing:last-child { .todo-list li.editing:last-child {
margin-bottom: -1px; margin-bottom: -1px;
} }
#footer { .footer {
color: #777; color: #777;
padding: 10px 15px; padding: 10px 15px;
height: 20px; height: 20px;
...@@ -254,7 +254,7 @@ label[for='toggle-all'] { ...@@ -254,7 +254,7 @@ label[for='toggle-all'] {
border-top: 1px solid #e6e6e6; border-top: 1px solid #e6e6e6;
} }
#footer:before { .footer:before {
content: ''; content: '';
position: absolute; position: absolute;
right: 0; right: 0;
...@@ -269,16 +269,16 @@ label[for='toggle-all'] { ...@@ -269,16 +269,16 @@ label[for='toggle-all'] {
0 17px 2px -6px rgba(0, 0, 0, 0.2); 0 17px 2px -6px rgba(0, 0, 0, 0.2);
} }
#todo-count { .todo-count {
float: left; float: left;
text-align: left; text-align: left;
} }
#todo-count strong { .todo-count strong {
font-weight: 300; font-weight: 300;
} }
#filters { .filters {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
...@@ -287,11 +287,11 @@ label[for='toggle-all'] { ...@@ -287,11 +287,11 @@ label[for='toggle-all'] {
left: 0; left: 0;
} }
#filters li { .filters li {
display: inline; display: inline;
} }
#filters li a { .filters li a {
color: inherit; color: inherit;
margin: 3px; margin: 3px;
padding: 3px 7px; padding: 3px 7px;
...@@ -300,17 +300,17 @@ label[for='toggle-all'] { ...@@ -300,17 +300,17 @@ label[for='toggle-all'] {
border-radius: 3px; border-radius: 3px;
} }
#filters li a.selected, .filters li a.selected,
#filters li a:hover { .filters li a:hover {
border-color: rgba(175, 47, 47, 0.1); border-color: rgba(175, 47, 47, 0.1);
} }
#filters li a.selected { .filters li a.selected {
border-color: rgba(175, 47, 47, 0.2); border-color: rgba(175, 47, 47, 0.2);
} }
#clear-completed, .clear-completed,
html #clear-completed:active { html .clear-completed:active {
float: right; float: right;
position: relative; position: relative;
line-height: 20px; line-height: 20px;
...@@ -319,11 +319,11 @@ html #clear-completed:active { ...@@ -319,11 +319,11 @@ html #clear-completed:active {
position: relative; position: relative;
} }
#clear-completed:hover { .clear-completed:hover {
text-decoration: underline; text-decoration: underline;
} }
#info { .info {
margin: 65px auto 0; margin: 65px auto 0;
color: #bfbfbf; color: #bfbfbf;
font-size: 10px; font-size: 10px;
...@@ -331,17 +331,17 @@ html #clear-completed:active { ...@@ -331,17 +331,17 @@ html #clear-completed:active {
text-align: center; text-align: center;
} }
#info p { .info p {
line-height: 1; line-height: 1;
} }
#info a { .info a {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
font-weight: 400; font-weight: 400;
} }
#info a:hover { .info a:hover {
text-decoration: underline; text-decoration: underline;
} }
...@@ -350,16 +350,16 @@ html #clear-completed:active { ...@@ -350,16 +350,16 @@ html #clear-completed:active {
Can't use it globally since it destroys checkboxes in Firefox Can't use it globally since it destroys checkboxes in Firefox
*/ */
@media screen and (-webkit-min-device-pixel-ratio:0) { @media screen and (-webkit-min-device-pixel-ratio:0) {
#toggle-all, .toggle-all,
#todo-list li .toggle { .todo-list li .toggle {
background: none; background: none;
} }
#todo-list li .toggle { .todo-list li .toggle {
height: 40px; height: 40px;
} }
#toggle-all { .toggle-all {
-webkit-transform: rotate(90deg); -webkit-transform: rotate(90deg);
transform: rotate(90deg); transform: rotate(90deg);
-webkit-appearance: none; -webkit-appearance: none;
...@@ -368,11 +368,11 @@ html #clear-completed:active { ...@@ -368,11 +368,11 @@ html #clear-completed:active {
} }
@media (max-width: 430px) { @media (max-width: 430px) {
#footer { .footer {
height: 50px; height: 50px;
} }
#filters { .filters {
bottom: 10px; bottom: 10px;
} }
} }
...@@ -114,7 +114,12 @@ ...@@ -114,7 +114,12 @@
})({}); })({});
if (location.hostname === 'todomvc.com') { if (location.hostname === 'todomvc.com') {
window._gaq = [['_setAccount','UA-31081062-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script')); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-31081062-1', 'auto');
ga('send', 'pageview');
} }
/* jshint ignore:end */ /* jshint ignore:end */
...@@ -228,7 +233,7 @@ ...@@ -228,7 +233,7 @@
xhr.onload = function (e) { xhr.onload = function (e) {
var parsedResponse = JSON.parse(e.target.responseText); var parsedResponse = JSON.parse(e.target.responseText);
if (parsedResponse instanceof Array) { if (parsedResponse instanceof Array) {
var count = parsedResponse.length var count = parsedResponse.length;
if (count !== 0) { if (count !== 0) {
issueLink.innerHTML = 'This app has ' + count + ' open issues'; issueLink.innerHTML = 'This app has ' + count + ' open issues';
document.getElementById('issue-count').style.display = 'inline'; document.getElementById('issue-count').style.display = 'inline';
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"todomvc-common": "^1.0.1", "todomvc-common": "^1.0.1",
"todomvc-app-css": "^1.0.1" "todomvc-app-css": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
"jasmine-core": "^0.3.0" "jasmine-core": "^2.0.0"
} }
} }
/*global app, jasmine, describe, it, beforeEach, expect */ /*global app, jasmine, describe, it, beforeEach, expect */
describe('controller', function () { describe('controller', function () {
'use strict'; 'use strict';
var subject, model, view; var subject, model, view;
var setUpModel = function (todos) { var setUpModel = function (todos) {
model.read.andCallFake(function (query, callback) { model.read.and.callFake(function (query, callback) {
callback = callback || query; callback = callback || query;
callback(todos); callback(todos);
}); });
model.getCount.andCallFake(function (callback) { model.getCount.and.callFake(function (callback) {
var todoCounts = { var todoCounts = {
active: todos.filter(function (todo) { active: todos.filter(function (todo) {
return !todo.completed; return !todo.completed;
}).length, }).length,
completed: todos.filter(function (todo) { completed: todos.filter(function (todo) {
return !!todo.completed; return !!todo.completed;
}).length, }).length,
total: todos.length total: todos.length
}; };
callback(todoCounts); callback(todoCounts);
}); });
model.remove.andCallFake(function (id, callback) { model.remove.and.callFake(function (id, callback) {
callback(); callback();
}); });
model.create.andCallFake(function (title, callback) { model.create.and.callFake(function (title, callback) {
callback(); callback();
}); });
model.update.andCallFake(function (id, updateData, callback) { model.update.and.callFake(function (id, updateData, callback) {
callback(); callback();
}); });
}; };
var createViewStub = function () { var createViewStub = function () {
var eventRegistry = {}; var eventRegistry = {};
return { return {
render: jasmine.createSpy('render'), render: jasmine.createSpy('render'),
bind: function (event, handler) { bind: function (event, handler) {
eventRegistry[event] = handler; eventRegistry[event] = handler;
}, },
trigger: function (event, parameter) { trigger: function (event, parameter) {
eventRegistry[event](parameter); eventRegistry[event](parameter);
} }
}; };
}; };
beforeEach(function () { beforeEach(function () {
model = jasmine.createSpyObj('model', ['read', 'getCount', 'remove', 'create', 'update']); model = jasmine.createSpyObj('model', ['read', 'getCount', 'remove', 'create', 'update']);
view = createViewStub(); view = createViewStub();
subject = new app.Controller(model, view); subject = new app.Controller(model, view);
}); });
it('should show entries on start-up', function () { it('should show entries on start-up', function () {
setUpModel([]); setUpModel([]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('showEntries', []); expect(view.render).toHaveBeenCalledWith('showEntries', []);
}); });
describe('routing', function () { describe('routing', function () {
it('should show all entries without a route', function () { it('should show all entries without a route', function () {
var todo = {title: 'my todo'}; var todo = {title: 'my todo'};
setUpModel([todo]); setUpModel([todo]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('showEntries', [todo]); expect(view.render).toHaveBeenCalledWith('showEntries', [todo]);
}); });
it('should show all entries without "all" route', function () { it('should show all entries without "all" route', function () {
var todo = {title: 'my todo'}; var todo = {title: 'my todo'};
setUpModel([todo]); setUpModel([todo]);
subject.setView('#/'); subject.setView('#/');
expect(view.render).toHaveBeenCalledWith('showEntries', [todo]); expect(view.render).toHaveBeenCalledWith('showEntries', [todo]);
}); });
it('should show active entries', function () { it('should show active entries', function () {
var todo = {title: 'my todo', completed: false}; var todo = {title: 'my todo', completed: false};
setUpModel([todo]); setUpModel([todo]);
subject.setView('#/active'); subject.setView('#/active');
expect(model.read).toHaveBeenCalledWith({completed: false}, jasmine.any(Function)); expect(model.read).toHaveBeenCalledWith({completed: false}, jasmine.any(Function));
expect(view.render).toHaveBeenCalledWith('showEntries', [todo]); expect(view.render).toHaveBeenCalledWith('showEntries', [todo]);
}); });
it('should show completed entries', function () { it('should show completed entries', function () {
var todo = {title: 'my todo', completed: true}; var todo = {title: 'my todo', completed: true};
setUpModel([todo]); setUpModel([todo]);
subject.setView('#/completed'); subject.setView('#/completed');
expect(model.read).toHaveBeenCalledWith({completed: true}, jasmine.any(Function)); expect(model.read).toHaveBeenCalledWith({completed: true}, jasmine.any(Function));
expect(view.render).toHaveBeenCalledWith('showEntries', [todo]); expect(view.render).toHaveBeenCalledWith('showEntries', [todo]);
}); });
}); });
it('should show the content block when todos exists', function () { it('should show the content block when todos exists', function () {
setUpModel([{title: 'my todo', completed: true}]); setUpModel([{title: 'my todo', completed: true}]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('contentBlockVisibility', { expect(view.render).toHaveBeenCalledWith('contentBlockVisibility', {
visible: true visible: true
}); });
}); });
it('should hide the content block when no todos exists', function () { it('should hide the content block when no todos exists', function () {
setUpModel([]); setUpModel([]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('contentBlockVisibility', { expect(view.render).toHaveBeenCalledWith('contentBlockVisibility', {
visible: false visible: false
}); });
}); });
it('should check the toggle all button, if all todos are completed', function () { it('should check the toggle all button, if all todos are completed', function () {
setUpModel([{title: 'my todo', completed: true}]); setUpModel([{title: 'my todo', completed: true}]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('toggleAll', { expect(view.render).toHaveBeenCalledWith('toggleAll', {
checked: true checked: true
}); });
}); });
it('should set the "clear completed" button', function () { it('should set the "clear completed" button', function () {
var todo = {id: 42, title: 'my todo', completed: true}; var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]); setUpModel([todo]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('clearCompletedButton', { expect(view.render).toHaveBeenCalledWith('clearCompletedButton', {
completed: 1, completed: 1,
visible: true visible: true
}); });
}); });
it('should highlight "All" filter by default', function () { it('should highlight "All" filter by default', function () {
setUpModel([]); setUpModel([]);
subject.setView(''); subject.setView('');
expect(view.render).toHaveBeenCalledWith('setFilter', ''); expect(view.render).toHaveBeenCalledWith('setFilter', '');
}); });
it('should highlight "Active" filter when switching to active view', function () { it('should highlight "Active" filter when switching to active view', function () {
setUpModel([]); setUpModel([]);
subject.setView('#/active'); subject.setView('#/active');
expect(view.render).toHaveBeenCalledWith('setFilter', 'active'); expect(view.render).toHaveBeenCalledWith('setFilter', 'active');
}); });
describe('toggle all', function () { describe('toggle all', function () {
it('should toggle all todos to completed', function () { it('should toggle all todos to completed', function () {
var todos = [{ var todos = [{
id: 42, id: 42,
title: 'my todo', title: 'my todo',
completed: false completed: false
}, { }, {
id: 21, id: 21,
title: 'another todo', title: 'another todo',
completed: false completed: false
}]; }];
setUpModel(todos);
subject.setView('');
view.trigger('toggleAll', {completed: true}); setUpModel(todos);
subject.setView('');
expect(model.update).toHaveBeenCalledWith(42, {completed: true}, jasmine.any(Function)); view.trigger('toggleAll', {completed: true});
expect(model.update).toHaveBeenCalledWith(21, {completed: true}, jasmine.any(Function));
});
it('should update the view', function () { expect(model.update).toHaveBeenCalledWith(42, {completed: true}, jasmine.any(Function));
var todos = [{ expect(model.update).toHaveBeenCalledWith(21, {completed: true}, jasmine.any(Function));
id: 42, });
title: 'my todo',
completed: true
}];
setUpModel(todos);
subject.setView('');
view.trigger('toggleAll', {completed: false}); it('should update the view', function () {
var todos = [{
id: 42,
title: 'my todo',
completed: true
}];
expect(view.render).toHaveBeenCalledWith('elementComplete', {id : 42, completed : false}); setUpModel(todos);
}); subject.setView('');
});
describe('new todo', function () { view.trigger('toggleAll', {completed: false});
it('should add a new todo to the model', function () {
setUpModel([]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('elementComplete', {id : 42, completed : false});
});
});
view.trigger('newTodo', 'a new todo'); describe('new todo', function () {
it('should add a new todo to the model', function () {
setUpModel([]);
expect(model.create).toHaveBeenCalledWith('a new todo', jasmine.any(Function)); subject.setView('');
});
it('should add a new todo to the view', function () { view.trigger('newTodo', 'a new todo');
setUpModel([]);
subject.setView(''); expect(model.create).toHaveBeenCalledWith('a new todo', jasmine.any(Function));
});
view.render.reset(); it('should add a new todo to the view', function () {
model.read.reset(); setUpModel([]);
model.read.andCallFake(function (callback) {
callback([{
title: 'a new todo',
completed: false
}]);
});
view.trigger('newTodo', 'a new todo'); subject.setView('');
expect(model.read).toHaveBeenCalled(); view.render.calls.reset();
model.read.calls.reset();
model.read.and.callFake(function (callback) {
callback([{
title: 'a new todo',
completed: false
}]);
});
expect(view.render).toHaveBeenCalledWith('showEntries', [{ view.trigger('newTodo', 'a new todo');
title: 'a new todo',
completed: false
}]);
});
it('should clear the input field when a new todo is added', function () { expect(model.read).toHaveBeenCalled();
setUpModel([]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('showEntries', [{
title: 'a new todo',
completed: false
}]);
});
view.trigger('newTodo', 'a new todo'); it('should clear the input field when a new todo is added', function () {
setUpModel([]);
expect(view.render).toHaveBeenCalledWith('clearNewTodo'); subject.setView('');
});
});
describe('element removal', function () { view.trigger('newTodo', 'a new todo');
it('should remove an entry from the model', function () {
var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('clearNewTodo');
view.trigger('itemRemove', {id: 42}); });
});
expect(model.remove).toHaveBeenCalledWith(42, jasmine.any(Function)); describe('element removal', function () {
}); it('should remove an entry from the model', function () {
var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]);
it('should remove an entry from the view', function () { subject.setView('');
var todo = {id: 42, title: 'my todo', completed: true}; view.trigger('itemRemove', {id: 42});
setUpModel([todo]);
subject.setView(''); expect(model.remove).toHaveBeenCalledWith(42, jasmine.any(Function));
view.trigger('itemRemove', {id: 42}); });
expect(view.render).toHaveBeenCalledWith('removeItem', 42); it('should remove an entry from the view', function () {
}); var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]);
it('should update the element count', function () { subject.setView('');
var todo = {id: 42, title: 'my todo', completed: true}; view.trigger('itemRemove', {id: 42});
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('removeItem', 42);
view.trigger('itemRemove', {id: 42}); });
expect(view.render).toHaveBeenCalledWith('updateElementCount', 0); it('should update the element count', function () {
}); var todo = {id: 42, title: 'my todo', completed: true};
}); setUpModel([todo]);
describe('remove completed', function () { subject.setView('');
it('should remove a completed entry from the model', function () { view.trigger('itemRemove', {id: 42});
var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('updateElementCount', 0);
view.trigger('removeCompleted'); });
});
expect(model.read).toHaveBeenCalledWith({completed: true}, jasmine.any(Function)); describe('remove completed', function () {
expect(model.remove).toHaveBeenCalledWith(42, jasmine.any(Function)); it('should remove a completed entry from the model', function () {
}); var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]);
it('should remove a completed entry from the view', function () { subject.setView('');
var todo = {id: 42, title: 'my todo', completed: true}; view.trigger('removeCompleted');
setUpModel([todo]);
subject.setView(''); expect(model.read).toHaveBeenCalledWith({completed: true}, jasmine.any(Function));
view.trigger('removeCompleted'); expect(model.remove).toHaveBeenCalledWith(42, jasmine.any(Function));
});
expect(view.render).toHaveBeenCalledWith('removeItem', 42); it('should remove a completed entry from the view', function () {
}); var todo = {id: 42, title: 'my todo', completed: true};
}); setUpModel([todo]);
describe('element complete toggle', function () { subject.setView('');
it('should update the model', function () { view.trigger('removeCompleted');
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView('');
view.trigger('itemToggle', {id: 21, completed: true}); expect(view.render).toHaveBeenCalledWith('removeItem', 42);
});
});
expect(model.update).toHaveBeenCalledWith(21, {completed: true}, jasmine.any(Function)); describe('element complete toggle', function () {
}); it('should update the model', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView('');
it('should update the view', function () { view.trigger('itemToggle', {id: 21, completed: true});
var todo = {id: 42, title: 'my todo', completed: true};
setUpModel([todo]);
subject.setView('');
view.trigger('itemToggle', {id: 42, completed: false}); expect(model.update).toHaveBeenCalledWith(21, {completed: true}, jasmine.any(Function));
});
expect(view.render).toHaveBeenCalledWith('elementComplete', {id: 42, completed: false}); it('should update the view', function () {
}); var todo = {id: 42, title: 'my todo', completed: true};
}); setUpModel([todo]);
subject.setView('');
describe('edit item', function () { view.trigger('itemToggle', {id: 42, completed: false});
it('should switch to edit mode', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('elementComplete', {id: 42, completed: false});
});
});
view.trigger('itemEdit', {id: 21}); describe('edit item', function () {
it('should switch to edit mode', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(view.render).toHaveBeenCalledWith('editItem', {id: 21, title: 'my todo'}); subject.setView('');
});
it('should leave edit mode on done', function () { view.trigger('itemEdit', {id: 21});
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('editItem', {id: 21, title: 'my todo'});
});
view.trigger('itemEditDone', {id: 21, title: 'new title'}); it('should leave edit mode on done', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(view.render).toHaveBeenCalledWith('editItemDone', {id: 21, title: 'new title'}); subject.setView('');
});
it('should persist the changes on done', function () { view.trigger('itemEditDone', {id: 21, title: 'new title'});
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('editItemDone', {id: 21, title: 'new title'});
});
view.trigger('itemEditDone', {id: 21, title: 'new title'}); it('should persist the changes on done', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(model.update).toHaveBeenCalledWith(21, {title: 'new title'}, jasmine.any(Function)); subject.setView('');
});
it('should remove the element from the model when persisting an empty title', function () { view.trigger('itemEditDone', {id: 21, title: 'new title'});
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(model.update).toHaveBeenCalledWith(21, {title: 'new title'}, jasmine.any(Function));
});
view.trigger('itemEditDone', {id: 21, title: ''}); it('should remove the element from the model when persisting an empty title', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(model.remove).toHaveBeenCalledWith(21, jasmine.any(Function)); subject.setView('');
});
it('should remove the element from the view when persisting an empty title', function () { view.trigger('itemEditDone', {id: 21, title: ''});
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(model.remove).toHaveBeenCalledWith(21, jasmine.any(Function));
});
view.trigger('itemEditDone', {id: 21, title: ''}); it('should remove the element from the view when persisting an empty title', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(view.render).toHaveBeenCalledWith('removeItem', 21); subject.setView('');
});
it('should leave edit mode on cancel', function () { view.trigger('itemEditDone', {id: 21, title: ''});
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('removeItem', 21);
});
view.trigger('itemEditCancel', {id: 21}); it('should leave edit mode on cancel', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(view.render).toHaveBeenCalledWith('editItemDone', {id: 21, title: 'my todo'}); subject.setView('');
});
it('should not persist the changes on cancel', function () { view.trigger('itemEditCancel', {id: 21});
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
subject.setView(''); expect(view.render).toHaveBeenCalledWith('editItemDone', {id: 21, title: 'my todo'});
});
view.trigger('itemEditCancel', {id: 21}); it('should not persist the changes on cancel', function () {
var todo = {id: 21, title: 'my todo', completed: false};
setUpModel([todo]);
expect(model.update).not.toHaveBeenCalled(); subject.setView('');
});
}); view.trigger('itemEditCancel', {id: 21});
expect(model.update).not.toHaveBeenCalled();
});
});
}); });
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>Jasmine Spec Runner</title> <title>Jasmine Spec Runner</title>
<link rel="stylesheet" href="../node_modules/jasmine/lib/jasmine-core/jasmine.css"> <link rel="stylesheet" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
<script src="../node_modules/jasmine/lib/jasmine-core/jasmine.js"></script> <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="../node_modules/jasmine/lib/jasmine-core/jasmine-html.js"></script> <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
<!-- include spec files here... --> <!-- include spec files here... -->
<script src="ControllerSpec.js"></script> <script src="ControllerSpec.js"></script>
<!-- include source files here... --> <script>
<script> // Bootstrap app data
// Bootstrap app data window.app = {};
window.app = {}; </script>
</script>
<script src="../js/helpers.js"></script>
<script src="../js/view.js"></script>
<script src="../js/controller.js"></script>
<script type="text/javascript"> <script src="../js/helpers.js"></script>
(function() { <script src="../js/view.js"></script>
var jasmineEnv = jasmine.getEnv(); <script src="../js/controller.js"></script>
</head>
var htmlReporter = new jasmine.HtmlReporter(); <body>
jasmineEnv.addReporter(htmlReporter); </body>
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
jasmineEnv.execute();
};
})();
</script>
</head>
<body>
</body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment