From f3ec40399e37428942564f681439902956576ed0 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sat, 30 Jan 2016 17:22:46 +0000 Subject: [PATCH 01/16] Env set up and test suites ready to go --- .gitignore | 2 ++ bower.json | 28 +++++++++++++++ index.html | 31 +++++++++++++++++ js/app.js | 1 + package.json | 31 +++++++++++++++++ test/e2e/conf.js | 4 +++ test/e2e/todoListFeature.js | 0 test/karma.conf.js | 68 +++++++++++++++++++++++++++++++++++++ 8 files changed, 165 insertions(+) create mode 100644 .gitignore create mode 100644 bower.json create mode 100644 index.html create mode 100644 js/app.js create mode 100644 package.json create mode 100644 test/e2e/conf.js create mode 100644 test/e2e/todoListFeature.js create mode 100644 test/karma.conf.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..75ce18e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bower_components +/node_modules diff --git a/bower.json b/bower.json new file mode 100644 index 00000000..1ed95ff7 --- /dev/null +++ b/bower.json @@ -0,0 +1,28 @@ +{ + "name": "todo_challenge", + "homepage": "https://github.com/TY231618/todo_challenge", + "authors": [ + "Tony Young " + ], + "description": "", + "main": "", + "moduleType": [], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "jquery": "^2.2.0", + "bootstrap": "^3.3.6", + "angular": "^1.4.9", + "angular-resource": "^1.4.9" + }, + "devDependencies": { + "angular-mocks": "^1.4.9", + "angular-route": "^1.4.9" + } +} diff --git a/index.html b/index.html new file mode 100644 index 00000000..aa37a56a --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + + + + + Github user search + + + + + + + + +
+
+ + +
+ + +
+ + diff --git a/js/app.js b/js/app.js new file mode 100644 index 00000000..148358c7 --- /dev/null +++ b/js/app.js @@ -0,0 +1 @@ +var todoList = angular.module('TodoList', ['ngResource']); diff --git a/package.json b/package.json new file mode 100644 index 00000000..d3da8189 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "todo_challenge", + "version": "1.0.0", + "description": "* Deadline: submit completed pull request by 9am on Monday * You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript", + "main": "index.js", + "directories": { + "doc": "docs" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/TY231618/todo_challenge.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/TY231618/todo_challenge/issues" + }, + "homepage": "https://github.com/TY231618/todo_challenge#readme", + "devDependencies": { + "jasmine-core": "^2.4.1", + "karma": "^0.13.19", + "karma-chrome-launcher": "^0.2.2", + "karma-jasmine": "^0.3.6", + "karma-phantomjs-launcher": "^1.0.0", + "phantomjs": "^2.1.3", + "protractor": "^3.0.0" + } +} diff --git a/test/e2e/conf.js b/test/e2e/conf.js new file mode 100644 index 00000000..367e45b1 --- /dev/null +++ b/test/e2e/conf.js @@ -0,0 +1,4 @@ +exports.config = { + seleniumAddress: 'http://localhost:4444/wd/hub', + specs: ['todoListFeature.js'] +} diff --git a/test/e2e/todoListFeature.js b/test/e2e/todoListFeature.js new file mode 100644 index 00000000..e69de29b diff --git a/test/karma.conf.js b/test/karma.conf.js new file mode 100644 index 00000000..e0998aef --- /dev/null +++ b/test/karma.conf.js @@ -0,0 +1,68 @@ +// Karma configuration +// Generated on Thu Nov 27 2014 10:43:21 GMT+0000 (GMT) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '../', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'bower_components/angular/angular.js', + 'bower_components/angular-route/angular-route.js', + 'bower_components/angular-resource/angular-resource.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'js/**/*.js', + 'test/**/*.spec.js' + ], + + + // list of files to exclude + exclude: [], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: {}, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; From 6bd90f96350b2a76c713a6f249594f377260ac9a Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sat, 30 Jan 2016 18:13:10 +0000 Subject: [PATCH 02/16] Added contoller --- .jshintrc | 2 +- index.html | 9 +++++++-- js/todoListController.js | 7 +++++++ test/todoListControllerFeature.spec.js | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 js/todoListController.js create mode 100644 test/todoListControllerFeature.spec.js diff --git a/.jshintrc b/.jshintrc index cd595a55..0fca0917 100644 --- a/.jshintrc +++ b/.jshintrc @@ -89,5 +89,5 @@ "yui" : false, // Yahoo User Interface // Custom Globals - "globals" : { "toDoList": true, "angular": true } // additional predefined global variables + "globals" : { "todoList": true, "angular": true } // additional predefined global variables } diff --git a/index.html b/index.html index aa37a56a..bc7625cd 100644 --- a/index.html +++ b/index.html @@ -2,20 +2,24 @@ - Github user search + Todo List + + -
+
+ {{todo.list.title}} : {{todo.list.done}} + +
diff --git a/js/todoListController.js b/js/todoListController.js new file mode 100644 index 00000000..fd5a4980 --- /dev/null +++ b/js/todoListController.js @@ -0,0 +1,7 @@ +todoList.controller('TodoListController', function() { + this.list = todos; +}); + +var todos = { + 'title': 'shower', 'done': false +} diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js new file mode 100644 index 00000000..0d25de1c --- /dev/null +++ b/test/todoListControllerFeature.spec.js @@ -0,0 +1,14 @@ +describe('TodoListController', function() { + beforeEach(module('TodoList')); + + var ctrl; + + beforeEach(inject(function($controller) { + ctrl = $controller('TodoListController'); + })); + + it('initialises with an empty search result and term', function() { + expect(ctrl.searchResult).toBeUndefined(); + expect(ctrl.searchTerm).toBeUndefined(); + }); +}); From 13420ac7d706986f72c05f4f946a3d681990a5b8 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sat, 30 Jan 2016 18:27:22 +0000 Subject: [PATCH 03/16] First protractor test green --- index.html | 2 +- js/todoListController.js | 2 +- package.json | 3 +++ test/e2e/todoListFeature.js | 12 ++++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index bc7625cd..8c19e29f 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ - Todo List + Todo List Challenge diff --git a/js/todoListController.js b/js/todoListController.js index fd5a4980..ca506bdb 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -3,5 +3,5 @@ todoList.controller('TodoListController', function() { }); var todos = { - 'title': 'shower', 'done': false + 'title': 'shower', 'done': false, } diff --git a/package.json b/package.json index d3da8189..162c5398 100644 --- a/package.json +++ b/package.json @@ -27,5 +27,8 @@ "karma-phantomjs-launcher": "^1.0.0", "phantomjs": "^2.1.3", "protractor": "^3.0.0" + }, + "dependencies": { + "http-server": "^0.8.5" } } diff --git a/test/e2e/todoListFeature.js b/test/e2e/todoListFeature.js index e69de29b..a78ab1df 100644 --- a/test/e2e/todoListFeature.js +++ b/test/e2e/todoListFeature.js @@ -0,0 +1,12 @@ +describe('Todo List', function() { + + + beforeEach(function() { + browser.get('http://localhost:8080'); + }); + + it('has a title', function() { + expect(browser.getTitle()).toEqual('Todo List Challenge'); + }); + +}); From 38b06720e92c2bd048d4855186058eb0b3aa18dc Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 09:23:01 +0000 Subject: [PATCH 04/16] Can add a new todo, green test --- css/main.css | 13 +++++++++++++ index.html | 22 +++++++++++++++------- js/todoListController.js | 16 +++++++++++----- test/todoListControllerFeature.spec.js | 7 +++++++ 4 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 css/main.css diff --git a/css/main.css b/css/main.css new file mode 100644 index 00000000..7f5fc6e6 --- /dev/null +++ b/css/main.css @@ -0,0 +1,13 @@ +body { + text-align: center; +} + +.done { + text-decoration: line-through; color: #ccc; +} + +.center{ + width:200px; + margin:0 auto; + text-align:left; +} diff --git a/index.html b/index.html index 8c19e29f..651d4206 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ Todo List Challenge + @@ -12,14 +13,21 @@ - -
-
- - + +
+
+ + +
+ - {{todo.list.title}} : {{todo.list.done}} - +
+
    +
  • + + {{list.title}} +
  • +
- + +
diff --git a/js/todoListController.js b/js/todoListController.js index 73b00ae8..312adc8d 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -4,10 +4,12 @@ todoList.controller('TodoListController', function() { self.todos = []; self.addTodo = function(newTodo){ - self.todos.push({'title': newTodo, 'done': false}); + self.todos.push({title: newTodo, done: false}); + self.newTodo = ''; }; - // self.addTask = function(taskname){ - // self.taskList.push({task: taskname, completed: false}) - // }; + // self.clearList = function(){ + // self.todos = 0; + // }; + }); diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index bf2d9f74..6cbc70ee 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -15,6 +15,7 @@ describe('TodoListController', function() { describe('new todo', function(){ it('adds a todo to a list', function(){ ctrl.addTodo('set alarm'); + expect(ctrl.newTodo).toEqual(''); expect(ctrl.todos[0].title).toEqual("set alarm"); }); From f3749d1c0d8c07e216f1c66598b9292cb21c7f3e Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 13:41:15 +0000 Subject: [PATCH 07/16] user can remove completed tasks --- index.html | 8 ++++++-- js/todoListController.js | 10 ++++++++++ test/todoListControllerFeature.spec.js | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index a5456ab9..340afbee 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,14 @@ + + Todo List Challenge + + @@ -19,7 +23,8 @@

- + +

@@ -31,7 +36,6 @@ -
diff --git a/js/todoListController.js b/js/todoListController.js index 312adc8d..4715838f 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -8,6 +8,16 @@ todoList.controller('TodoListController', function() { self.newTodo = ''; }; + self.removeTask = function () { + var oldList = self.todos; + self.todos = []; + + for (var i = 0; i < oldList.length; i++) { + if (!oldList[i].done) { + self.todos.push(oldList[i]); + } + } + } // self.clearList = function(){ // self.todos = 0; // }; diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index 6cbc70ee..ba605ad0 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -24,4 +24,13 @@ describe('TodoListController', function() { expect(ctrl.todos[0].done).toEqual(false) }) }); + + describe('#removeTask', function(){ + it('', function() { + ctrl.addTodo('set alarm'); + ctrl.todos[0].done = true; + ctrl.removeTask(); + expect(ctrl.todos.length).toEqual(0); + }) + }) }); From 95069f56e17dba4062d23355b77ece441a90a517 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 17:59:01 +0000 Subject: [PATCH 08/16] displays a seperate list for completed tasks --- .gitignore | 1 + css/main.css | 9 +++++++++ index.html | 7 +++++-- js/todoListController.js | 24 +++++++++++++++++------- test/todoListControllerFeature.spec.js | 10 ++++++++++ 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 75ce18e9..347f7730 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /bower_components /node_modules +/random.js diff --git a/css/main.css b/css/main.css index 7f5fc6e6..459ce178 100644 --- a/css/main.css +++ b/css/main.css @@ -1,5 +1,14 @@ body { text-align: center; + background-image: url(/Users/TY/Desktop/stickynote.jpg); +} + +h2 { + font-family: Consolas, Sans-Serif; + width:800px; + margin:10px auto; + text-align:left; + padding:10px; } .done { diff --git a/index.html b/index.html index 340afbee..966f3a01 100644 --- a/index.html +++ b/index.html @@ -25,10 +25,13 @@
- + + -
+ +

+

My list of todos.....

  • {{list.title}} diff --git a/js/todoListController.js b/js/todoListController.js index 4715838f..13d5eb48 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -2,6 +2,8 @@ todoList.controller('TodoListController', function() { var self = this; self.todos = []; + self.filteredTasklist = []; + self.oldList = []; self.addTodo = function(newTodo){ self.todos.push({title: newTodo, done: false}); @@ -9,17 +11,25 @@ todoList.controller('TodoListController', function() { }; self.removeTask = function () { - var oldList = self.todos; + self.oldList = self.todos; self.todos = []; - for (var i = 0; i < oldList.length; i++) { - if (!oldList[i].done) { - self.todos.push(oldList[i]); + for (var i = 0; i < self.oldList.length; i++) { + if (!self.oldList[i].done) { + self.todos.push(self.oldList[i]); + } + } + } + + self.completedTask = function () { + self.oldList = self.todos; + self.todos = []; + + for (var i = 0; i < self.oldList.length; i++) { + if (self.oldList[i].done) { + self.todos.push(self.oldList[i]); } } } - // self.clearList = function(){ - // self.todos = 0; - // }; }); diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index ba605ad0..c8306080 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -33,4 +33,14 @@ describe('TodoListController', function() { expect(ctrl.todos.length).toEqual(0); }) }) + + describe('#completedTask', function () { + it('displays all completed tasks', function () { + ctrl.addTodo('set alarm'); + ctrl.addTodo('make breakfast'); + ctrl.todos[0].done = true; + ctrl.completedTask(); + expect(ctrl.todos.length).toEqual(1); + }); + }); }); From 4aa66d025be3dd8c6f4edbc21333f6713ab8f377 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 18:09:55 +0000 Subject: [PATCH 09/16] displays a seperate list for active tasks --- index.html | 2 +- js/todoListController.js | 33 ++++++++++++++++++++++---- test/todoListControllerFeature.spec.js | 10 ++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 966f3a01..91f740f8 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@ - + diff --git a/js/todoListController.js b/js/todoListController.js index 13d5eb48..c5ad01e6 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -2,28 +2,35 @@ todoList.controller('TodoListController', function() { var self = this; self.todos = []; - self.filteredTasklist = []; + self.filteredTodoList = []; self.oldList = []; self.addTodo = function(newTodo){ + self.filterAll(); self.todos.push({title: newTodo, done: false}); self.newTodo = ''; + self.filteredTodoList = self.todos; + }; self.removeTask = function () { - self.oldList = self.todos; - self.todos = []; + self.filterAll(); + self.oldList = self.todos; + self.todos = []; + for (var i = 0; i < self.oldList.length; i++) { if (!self.oldList[i].done) { self.todos.push(self.oldList[i]); } } + self.filteredTodoList = self.todos; + } self.completedTask = function () { - self.oldList = self.todos; - self.todos = []; + self.oldList = self.filteredTodoList; + self.todos = []; for (var i = 0; i < self.oldList.length; i++) { if (self.oldList[i].done) { @@ -32,4 +39,20 @@ todoList.controller('TodoListController', function() { } } + self.activeTask = function () { + self.oldList = self.filteredTodoList; + self.todos = []; + + for (var i = 0; i < self.oldList.length; i++) { + if (!self.oldList[i].done) { + self.todos.push(self.oldList[i]); + } + } + } + + self.filterAll = function () { + self.taskList = self.filteredTodoList; + } + + }); diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index c8306080..5f98b66e 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -43,4 +43,14 @@ describe('TodoListController', function() { expect(ctrl.todos.length).toEqual(1); }); }); + + describe('#activeTask', function () { + it('displays all active tasks', function () { + ctrl.addTodo('set alarm'); + ctrl.addTodo('make breakfast'); + ctrl.todos[0].done = true; + ctrl.activeTask(); + expect(ctrl.todos.length).toEqual(1); + }); + }); }); From 90cff040292bcf3eaeb0f385244b9f2a50442629 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 18:17:17 +0000 Subject: [PATCH 10/16] displays a seperate list for all tasks --- index.html | 7 ++++--- js/todoListController.js | 14 +++++++------- test/todoListControllerFeature.spec.js | 26 ++++++++++++++++++-------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 91f740f8..13b75149 100644 --- a/index.html +++ b/index.html @@ -24,9 +24,10 @@
    - - - + + + + diff --git a/js/todoListController.js b/js/todoListController.js index c5ad01e6..9f0596ec 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -6,15 +6,15 @@ todoList.controller('TodoListController', function() { self.oldList = []; self.addTodo = function(newTodo){ - self.filterAll(); + self.allTodo(); self.todos.push({title: newTodo, done: false}); self.newTodo = ''; self.filteredTodoList = self.todos; }; - self.removeTask = function () { - self.filterAll(); + self.removeTodo = function () { + self.allTodo(); self.oldList = self.todos; self.todos = []; @@ -28,7 +28,7 @@ todoList.controller('TodoListController', function() { } - self.completedTask = function () { + self.completedTodo = function () { self.oldList = self.filteredTodoList; self.todos = []; @@ -39,7 +39,7 @@ todoList.controller('TodoListController', function() { } } - self.activeTask = function () { + self.activeTodo = function () { self.oldList = self.filteredTodoList; self.todos = []; @@ -50,8 +50,8 @@ todoList.controller('TodoListController', function() { } } - self.filterAll = function () { - self.taskList = self.filteredTodoList; + self.allTodo = function () { + self.todos = self.filteredTodoList; } diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index 5f98b66e..8d14be95 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -25,31 +25,41 @@ describe('TodoListController', function() { }) }); - describe('#removeTask', function(){ + describe('#removeTodo', function(){ it('', function() { ctrl.addTodo('set alarm'); ctrl.todos[0].done = true; - ctrl.removeTask(); + ctrl.removeTodo(); expect(ctrl.todos.length).toEqual(0); }) }) - describe('#completedTask', function () { - it('displays all completed tasks', function () { + describe('#completedTodo', function () { + it('displays all completed todos', function () { ctrl.addTodo('set alarm'); ctrl.addTodo('make breakfast'); ctrl.todos[0].done = true; - ctrl.completedTask(); + ctrl.completedTodo(); expect(ctrl.todos.length).toEqual(1); }); }); - describe('#activeTask', function () { - it('displays all active tasks', function () { + describe('#activeTodo', function () { + it('displays all active todos', function () { ctrl.addTodo('set alarm'); ctrl.addTodo('make breakfast'); ctrl.todos[0].done = true; - ctrl.activeTask(); + ctrl.activeTodo(); + expect(ctrl.todos.length).toEqual(1); + }); + }); + + describe('#allTodo', function () { + it('displays all todos', function () { + ctrl.addTodo('set alarm'); + ctrl.addTodo('make breakfast'); + ctrl.todos[0].done = true; + ctrl.activeTodo(); expect(ctrl.todos.length).toEqual(1); }); }); From b4adadf421330b7c511ee599c0676e69ceffbcf9 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 18:23:19 +0000 Subject: [PATCH 11/16] Displays number of todos for all, active and completed lists --- index.html | 2 +- js/todoListController.js | 3 +++ test/todoListControllerFeature.spec.js | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 13b75149..dd3de863 100644 --- a/index.html +++ b/index.html @@ -39,7 +39,7 @@

    My list of todos.....

- +

Number of Todos: {{todoCtrl.countTodo()}}

diff --git a/js/todoListController.js b/js/todoListController.js index 9f0596ec..8c1644c1 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -54,5 +54,8 @@ todoList.controller('TodoListController', function() { self.todos = self.filteredTodoList; } + self.countTodo = function () { + return self.todos.length; + } }); diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index 8d14be95..5f5e5795 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -63,4 +63,19 @@ describe('TodoListController', function() { expect(ctrl.todos.length).toEqual(1); }); }); + + describe('#countTodo', function () { + it('displays number of todos for all, active and completed lists', function () { + ctrl.addTodo('set alarm'); + ctrl.addTodo('make breakfast'); + ctrl.addTodo('go gym'); + ctrl.todos[0].done = true; + ctrl.activeTodo(); + expect(ctrl.todos.length).toEqual(2); + ctrl.completedTodo(); + expect(ctrl.todos.length).toEqual(1); + ctrl.allTodo(); + expect(ctrl.todos.length).toEqual(3); + }); + }); }); From ec6f681648921c729c5ef89e59a61e2026b0de2f Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 18:28:20 +0000 Subject: [PATCH 12/16] user can wipe whole list of todos --- index.html | 1 + js/todoListController.js | 4 ++++ test/todoListControllerFeature.spec.js | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/index.html b/index.html index dd3de863..c43b9545 100644 --- a/index.html +++ b/index.html @@ -28,6 +28,7 @@ + diff --git a/js/todoListController.js b/js/todoListController.js index 8c1644c1..8c0e912b 100644 --- a/js/todoListController.js +++ b/js/todoListController.js @@ -58,4 +58,8 @@ todoList.controller('TodoListController', function() { return self.todos.length; } + self.clearAll = function() { + self.todos = []; + self.filteredTodoList = []; + } }); diff --git a/test/todoListControllerFeature.spec.js b/test/todoListControllerFeature.spec.js index 5f5e5795..fb3b34d9 100644 --- a/test/todoListControllerFeature.spec.js +++ b/test/todoListControllerFeature.spec.js @@ -78,4 +78,20 @@ describe('TodoListController', function() { expect(ctrl.todos.length).toEqual(3); }); }); + + describe('#clearAll', function () { + it('displays all todos', function () { + ctrl.addTodo('set alarm'); + ctrl.addTodo('make breakfast'); + ctrl.addTodo('go gym'); + ctrl.todos[0].done = true; + ctrl.clearAll(); + ctrl.activeTodo(); + expect(ctrl.todos.length).toEqual(0); + ctrl.completedTodo(); + expect(ctrl.todos.length).toEqual(0); + ctrl.allTodo(); + expect(ctrl.todos.length).toEqual(0); + }); + }); }); From 41347a577685d28e4a7fec08f21d297fbeec2dc2 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 18:41:16 +0000 Subject: [PATCH 13/16] Updated README and added very basic styling --- .gitignore | 1 - README.md | 44 +------------------------------------------- css/main.css | 5 +++-- index.html | 14 +++++++------- 4 files changed, 11 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index 347f7730..75ce18e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /bower_components /node_modules -/random.js diff --git a/README.md b/README.md index 29dc834e..0d73f72a 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,4 @@ -# Todo Challenge - -* Deadline: submit completed pull request by 9am on Monday -* You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript - -Steps -------- - -1. Fill out your learning plan self review for the week: https://github.com/makersacademy/learning_plan -2. Fork this repo, and clone to your local machine -3. Complete the following challenge: - -## Challenge - -![Todo mockup](https://makersacademy.mybalsamiq.com/mockups/2914603.png?key=afabb09aef2901a2732515ae4349c1ec0458294b) +# Makers Academy Weekend Challenge: Todo List Build a Todo list as a mini front-end application. You don't have to use a database, the front-end is more important - you can use an appropriate data structure stored somewhere in your JavaScript (this time only!) @@ -30,11 +16,7 @@ So that I have more time to think about other things As a person who actually gets stuff done I want to mark my tasks as done So that I don't do them twice -``` - -Here are some other user stories you may choose to implement: -``` As a person with a lot of tasks I want to be able to filter my tasks by "All", "Active", "Complete" So that I only see the relevant tasks @@ -47,27 +29,3 @@ As someone who has done lots of stuff I want to be able to clear my completed tasks So I never see them again ``` - -As you may imagine, implementing a To-do list is very much a solved problem. However, we are mainly interested in seeing how you approach testing and design. We are looking for: - -* well written, well structured acceptance and unit tests -* clear and expressive JavaScript -* good HTML5 markup - -Don't worry about deployment, and make sure you read the CONTRIBUTING.md when submitting a pull request. - -## Extensions - -* Deploy the app -* Create a persistance layer (e.g. MongoDB), or use LocalStorage or the filesystem through Node -* Make it look purdy (CSS) - try a framework like Bootstrap or Foundation - -## CI - -Read the `.travis.yml` if any of the steps below don't make sense! - -* Make sure you have set up `npm test` in your `package.json` so that it runs your Karma tests -* Make sure you have your Protractor config file at `e2e/conf.js` -* Make sure `npm start` spins up whatever serves up your app - `http-server`, Sinatra or Node - -Good luck! diff --git a/css/main.css b/css/main.css index 459ce178..358d886d 100644 --- a/css/main.css +++ b/css/main.css @@ -9,14 +9,15 @@ h2 { margin:10px auto; text-align:left; padding:10px; + padding-left: 400px; } .done { text-decoration: line-through; color: #ccc; } -.center{ +/*.center{ width:200px; margin:0 auto; text-align:left; -} +}*/ diff --git a/index.html b/index.html index c43b9545..f15bbe9c 100644 --- a/index.html +++ b/index.html @@ -21,14 +21,14 @@
- -
- - - - + +

- + + + + +
From 002fe39aa7f90566c2f81a9e39155a19822f3a05 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 20:25:54 +0000 Subject: [PATCH 14/16] Updated README.md --- README.md | 9 ++++++++- css/main.css | 17 +++++++++++++---- index.html | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0d73f72a..c9bb6f22 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # Makers Academy Weekend Challenge: Todo List -Build a Todo list as a mini front-end application. You don't have to use a database, the front-end is more important - you can use an appropriate data structure stored somewhere in your JavaScript (this time only!) +The task is to build a Todo list as a mini front-end application. The main technologies used will be JavaScript, Angular, CSS and HTMl. I will be using TDD to drive the production of the app. + +Testing frameworks will include Karma for back-end and Protractor for front-end and user experience. Here are the core user stories: +================ ``` As a forgetful person @@ -29,3 +32,7 @@ As someone who has done lots of stuff I want to be able to clear my completed tasks So I never see them again ``` + +# Screen Shot + +![myimage-alt-tag](/Users/TY/Desktop/todo-screenshot.png) diff --git a/css/main.css b/css/main.css index 358d886d..ad5d196e 100644 --- a/css/main.css +++ b/css/main.css @@ -4,20 +4,29 @@ body { } h2 { - font-family: Consolas, Sans-Serif; + font-family: Sans-Serif; width:800px; margin:10px auto; text-align:left; padding:10px; - padding-left: 400px; + padding-left: 300px; } .done { text-decoration: line-through; color: #ccc; } -/*.center{ +.center{ width:200px; margin:0 auto; text-align:left; -}*/ +} + +p { + position: fixed; + bottom: 200px; + right: 800px; + font-family: Sans-Serif; + text-decoration: underline; + font-weight: bold; +} diff --git a/index.html b/index.html index f15bbe9c..85c1904b 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@
-
+


@@ -34,7 +34,7 @@

My list of todos.....

-
    +
    • {{list.title}} From 1308711c136b43d6078b592df55d9e44197f4cf1 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Sun, 31 Jan 2016 20:44:06 +0000 Subject: [PATCH 15/16] updated README.md some more --- README.md | 30 ++++++++++++++++++++++++++++++ css/main.css | 2 +- index.html | 8 ++++---- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c9bb6f22..5e723508 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,33 @@ So I never see them again # Screen Shot ![myimage-alt-tag](/Users/TY/Desktop/todo-screenshot.png) + +Setup +======== + +* Clone this repo and change into it with ``` cd todo_challenge```. +* If you don't already have them, install node and bower with ```$ brew install node``` and then ```$ npm install bower```. +* Install package dependencies by with ```$ npm install``` and ```$ bower install```. + +Usage +======== + +* Launch the app within your browser with ```$ open index.html```. +* To add a task, simply fill in the box and hit the ```Add Todo``` button. +* To mark a task as done just click the checkbox. +* You can remove completed todos with the ```Remove Completed Todo``` +* If you want to view just the active, completed or all todos you can use the buttons directly above the list. +* To permanently remove all todos, just use the ```Clear List``` button at the bottom. + +Tests +============= + +* To run the Karma tests for the Angular controller, you will need to have the Karma CLI installed, ```$ npm install -g karma-cli```. +* The tests can now be run with ```$ karma start spec/karma.conf.js```. +* When finished just use ```ctrl + c``` to exit. +* The Protractor tests require that you have the Java Development Kit installed. * You can check if you have it with ```$ java -version```. If you don't, you can get it from here. +* Protractor will also need to be installed globally with ```$ npm install -g protractor```. This will also install webdriver-manager. +* webdriver-manager will need to be updated to make sure it has the correct binaries to get an instance of Selenium Server running (what we'll be using for the tests). Do this with ```webdriver-manager update```. +* Now launch it with ```webdriver-manager start```. +* Now the app will need serving, do so with ```http-server```. +* Finally run the tests with ```$ protractor test/e2e/conf.js```. diff --git a/css/main.css b/css/main.css index ad5d196e..0b8d7dce 100644 --- a/css/main.css +++ b/css/main.css @@ -1,6 +1,6 @@ body { text-align: center; - background-image: url(/Users/TY/Desktop/stickynote.jpg); + background-image: url(/Users/TY/Desktop/todo-screenshot.jpg); } h2 { diff --git a/index.html b/index.html index 85c1904b..4fccf157 100644 --- a/index.html +++ b/index.html @@ -23,11 +23,11 @@

      - - - + + + - + From 57272ec61b545ef109b219cd387296b1bb1c975a Mon Sep 17 00:00:00 2001 From: Tony Young Date: Mon, 1 Feb 2016 13:34:36 +0000 Subject: [PATCH 16/16] updasted travis --- .travis.yml | 2 +- css/main.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd8e40aa..a4b04d75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ script: - node_modules/.bin/protractor test/e2e/conf.js --browser=firefox language: node_js node_js: - - "0.10" + - "5.4.1" before_script: - bower install - "export DISPLAY=:99.0" diff --git a/css/main.css b/css/main.css index 0b8d7dce..ad5d196e 100644 --- a/css/main.css +++ b/css/main.css @@ -1,6 +1,6 @@ body { text-align: center; - background-image: url(/Users/TY/Desktop/todo-screenshot.jpg); + background-image: url(/Users/TY/Desktop/stickynote.jpg); } h2 {