Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Jonathan Gardiner - ToDo List Challenge #144

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fd92ef9
initial bower setup
jelgar1 Jan 29, 2016
34a30ff
karma test env
jelgar1 Jan 29, 2016
17edeac
unit test for empty tasklist
jelgar1 Jan 29, 2016
07778b9
users can add tasks
jelgar1 Jan 30, 2016
81a225d
a task is not completed by default
jelgar1 Jan 30, 2016
45c34b5
users can mark a task as completed
jelgar1 Jan 30, 2016
9357b68
task counter
jelgar1 Jan 30, 2016
77e6d0b
delete single tasks
jelgar1 Jan 31, 2016
a58d10b
clear all tasks
jelgar1 Jan 31, 2016
821c0f6
edit a task
jelgar1 Jan 31, 2016
8f79df2
readme updated, clear completed tasks WIP
jelgar1 Jan 31, 2016
5f8b7dd
slight Readme tweak
jelgar1 Jan 31, 2016
3d03ebd
added a screenshot to readme
jelgar1 Jan 31, 2016
953a65f
clear completed tasks function working, protractor test WIP
jelgar1 Feb 1, 2016
7cdd517
protractor test now working for delete completed tasks
jelgar1 Feb 1, 2016
bffdc54
incomplete tasks
jelgar1 Mar 9, 2016
68ee764
formatting tweak
jelgar1 Mar 9, 2016
4870d31
npm start script added
jelgar1 Mar 9, 2016
d1f09e7
npm update
jelgar1 Mar 9, 2016
7fb5a4a
heroku tweak
jelgar1 Mar 9, 2016
0a432d1
heroku bug fixes
jelgar1 Mar 9, 2016
6d654f3
heroku bug fixes
jelgar1 Mar 9, 2016
9ae38b5
heroku tweak
jelgar1 Mar 9, 2016
5b431e8
start script
jelgar1 Mar 9, 2016
0372756
npm start in script
jelgar1 Mar 9, 2016
f5b659a
heroku build update
jelgar1 Mar 9, 2016
62a49fc
heroku
jelgar1 Mar 9, 2016
04abdd8
heroku
jelgar1 Mar 9, 2016
c595e55
heroku
jelgar1 Mar 9, 2016
c5dc636
package.json changed
jelgar1 Mar 9, 2016
f0352e4
heroku
jelgar1 Mar 9, 2016
5715042
heroku tweaks
jelgar1 Mar 9, 2016
c22e594
heroku tweaks
jelgar1 Mar 9, 2016
8649df5
readme updated
jelgar1 Mar 9, 2016
413fd4b
Update README.md
jelgar1 Mar 15, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bower_components/
node_modules/
28 changes: 28 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "todo_challenge",
"homepage": "https://github.com/jelgar1/todo_challenge",
"authors": [
"Jelgar <[email protected]>"
],
"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"
}
}
44 changes: 44 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
body {
color: black;
font-family: futura;
text-align: center;
background: url("../images/home_background.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

.main-box {
background-color: #778899;
margin:0 auto;
width: 60%;
text-align: center;
opacity: 0.9;
padding: 0.5%;
}

.completed-true {
text-decoration: line-through;
color: #ddd;
}

.btn {
font-family: futura;
}

.completed-editing {
border-color: red;
}

#todo-text {
width: 50%;
text-align: center;
font-family: futura;
}

#checkbox-form {
margin:0 auto;
width:40%;
text-align: left;
}
Binary file added images/home_background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en" ng-app="ToDoList">
<head>
<!-- <meta charset="utf-8"> -->
<title>Jon's ToDo List</title>
<!-- <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="js/app.js"></script>
<script src="js/toDoListController.js"></script>
</head>

<body ng-controller="ToDoListController as ctrl">
<div class="main-box">
<h1>ToDo List by Jonathan Gardiner</h1>
<h3>You currently have {{ctrl.taskCount()}} things to do.</h3>
<h3>What do you want to do?</h3>
<form class="todo-form">
<input type="text" value="What you do today can improve all your tomorrows" id="todo-text" ng-model="ctrl.taskname">
<button class="btn" id="todo-submit" ng-click="ctrl.addTask(ctrl.taskname)">Add task!</button>
</form>
<br>
<form id="checkbox-form" ng-repeat="task in ctrl.taskList">
<input type="checkbox" class="checkbox" ng-click="ctrl.taskCompleted($index)">
<span class="completed-{{task.completed}}" ng-hide="ctrl.isEditing($index)">{{task.taskname}}</span>
<input type="text" value="What you do today can improve all your tomorrows" ng-show="ctrl.isEditing($index)" id="edit-text" ng-show="ctrl.taskList[$index].completed==='editing'" ng-model='ctrl.taskList[$index].taskname'>
<button class="btn" id="edit" ng-click="ctrl.toggleEditMode($index)" ng-hide="ctrl.isEditing($index)">edit</button>
<button class="btn" id='submit-changes' ng-click="ctrl.updateTask($index, ctrl.taskList[$index].taskname)" ng-show="ctrl.isEditing($index)">submit</button>
<button class="cross" ng-click="ctrl.deleteTask($index)">x</button>
<br>
</form>
<br>
<button class="btn" id="clear-all" ng-click="ctrl.deleteAllTasks()">Clear all tasks</button>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var toDoList = angular.module('ToDoList', ['ngResource']);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'angular' is not defined.

41 changes: 41 additions & 0 deletions js/toDoListController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
toDoList.controller('ToDoListController', [function(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'toDoList' is not defined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has too many statements. (11)
'toDoList' is not defined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has too many statements. (11)
'toDoList' is not defined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has too many statements. (12)
'toDoList' is not defined.

var self = this;

this.taskList = [];

this.addTask = function(taskname){
this.taskList.push({taskname:taskname, completed:false});
this.taskname = null;
};

this.taskCompleted = function(index){
this.taskList[index].completed = !this.taskList[index].completed;
};

this.taskCount = function(){
return this.taskList.length;
};

this.deleteTask = function(index){
this.taskList.splice(index,1)
};

this.deleteAllTasks = function(){
this.taskList = [];
};

this.updateTask = function(index, taskname){
this.taskList.splice(index, 1, {taskname:taskname, completed:false});
};

this.toggleEditMode = function(index){
this.taskList[index].completed ='editing'
}
this.isEditing = function(index){
if(this.taskList[index].completed==='editing') {
return true;
} else {
return false;
}
};
}]);
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"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/jelgar1/todo_challenge.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jelgar1/todo_challenge/issues"
},
"homepage": "https://github.com/jelgar1/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",
"karma-spec-reporter": "0.0.23",
"phantomjs": "^2.1.3",
"protractor": "^3.0.0"
},
"dependencies": {
"http-server": "^0.8.5"
}
}
4 changes: 4 additions & 0 deletions test/e2e/conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['toDoFeatures.js']
}
70 changes: 70 additions & 0 deletions test/e2e/toDoFeatures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
describe('ToDo List', function() {

beforeEach(function() {
browser.get('http://localhost:8080');
});
var newTaskBox = element(by.model('ctrl.taskname'));
var addTaskBtn = element(by.id('todo-submit'))
var clearAllBtn = element(by.id('clear-all'))
var editBtn = element(by.id('edit'))
var editTextBox = element(by.id('edit-text'))
var submitChangesButton = element(by.id('submit-changes'))
it('has a title', function() {
expect(browser.getTitle()).toEqual("Jon's ToDo List");
});

describe('Adds a task to the list', function() {
beforeEach(function() {
newTaskBox.sendKeys('Feed the cat');
addTaskBtn.click();
});
it('can add tasks to the list', function() {
expect(element(by.className('completed-false')).getText()).
toEqual('Feed the cat');
});

describe('Marks task as complete', function() {
var taskCompletedBtn = element(by.className('checkbox'));
beforeEach(function() {
taskCompletedBtn.click();
});
it('allows users to mark tasks as completed', function() {
expect(element(by.className('completed-true')).isPresent()).toBe(true);
});

it('allows users to mark tasks as incomplete again', function() {
taskCompletedBtn.click();
expect(element(by.className('completed-false')).isPresent()).toBe(true);
});
});

describe('Deletes a task', function() {
var deleteTaskBtn = element(by.className('cross'))
beforeEach(function() {
deleteTaskBtn.click();
});
it('allows users to delete a task', function() {
expect(element(by.className('completed-false')).isPresent()).toBeFalsy();
});
});

it('counts the number of tasks on the list', function() {
expect(element(by.binding('ctrl.taskCount()')).getText()).toEqual('You currently have 1 things to do.');
});

it('allows users to clear all tasks', function() {
newTaskBox.sendKeys('Learn Angular');
addTaskBtn.click();
clearAllBtn.click();
expect(element(by.className('completed-false')).isPresent()).toBeFalsy();
});

it('allows users to edit a task', function(){
editBtn.click();
editTextBox.sendKeys(' EDITED');
submitChangesButton.click();
expect(element(by.className('completed-false')).getText()).
toEqual('Feed the cat EDITED');
});
});
});
74 changes: 74 additions & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Karma configuration
// Generated on Fri Jan 29 2016 16:00:12 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: ['spec'],


// 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,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
50 changes: 50 additions & 0 deletions test/todoListController.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
describe('ToDoListController', function() {
beforeEach(module('ToDoList'));

var ctrl;

beforeEach(inject(function($controller) {
ctrl = $controller('ToDoListController');
}));

it('initializes with an empty list', function(){
expect(ctrl.taskList).toEqual([]);
});

describe('A task is added', function() {
beforeEach(inject(function() {
ctrl.addTask('Feed the cat');
}))

it('can add a task to the list', function() {
expect(ctrl.taskList[0].taskname).toContain('Feed the cat');
});

it('sets a task as not completed by default', function() {
expect(ctrl.taskList[0].completed).toEqual(false);
});

it('can set a task as completed', function() {
ctrl.taskCompleted(0);
expect(ctrl.taskList[0].completed).toEqual(true);
});

it('counts the number of incomplete tasks', function() {
expect(ctrl.taskCount()).toEqual(1);
});

it('deletes a task', function(){
ctrl.deleteTask(0);
expect(ctrl.taskList[0]).not.toBeDefined();
});
it('clears all tasks', function(){
ctrl.addTask('Learn AngularJS');
ctrl.deleteAllTasks();
expect(ctrl.taskList[0]).not.toBeDefined();
});
it('edits a task', function() {
ctrl.updateTask(0, 'Feed the cat EDITED');
expect(ctrl.taskList[0].taskname).toEqual('Feed the cat EDITED');
});
});
});