forked from FirebaseExtended/angularfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
default: test | ||
|
||
test: | ||
ROOTDIR=`pwd` casperjs test tests/ | ||
casperjs test tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!doctype html> | ||
<html lang="en" ng-app="todo"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>AngularFire TODO Test</title> | ||
<link rel="stylesheet" type="text/css" href="https://www.firebase.com/css/example.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.3/angular.min.js"></script> | ||
<script src="https://cdn.firebase.com/v0/firebase.js"></script> | ||
<script src="../angularFire.js"></script> | ||
<style> | ||
#new-todo { | ||
width: 100%; | ||
margin: 10px; | ||
} | ||
.edit { | ||
width: 75%; | ||
} | ||
</style> | ||
</head> | ||
<body ng-controller="Todo"> | ||
<p></p> | ||
<form id="todo-form" ng-submit="addTodo()"> | ||
<input id="new-todo" placeholder="What needs to be done?" ng-model="newTodo" autofocus> | ||
</form> | ||
<div id="messagesDiv" style="height:500px;"> | ||
<div ng-cloak ng-repeat="todo in todos"> | ||
<div class="todoView"> | ||
<input class="toggle" type="checkbox" ng-model="todo.completed"/> | ||
<input class="edit" ng-model="todo.title"/> | ||
<button ng-click="removeTodo(todo)">Remove</button> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript"> | ||
var _scope = null; | ||
var _url = 'https://angularFireTests.firebaseio-demo.com/todo'; | ||
|
||
angular.module("todo", ["firebase"]); | ||
function Todo($scope, angularFire) { | ||
_scope = $scope; | ||
|
||
$scope.newTodo = ''; | ||
$scope.editedTodo = null; | ||
|
||
angularFire(_url, $scope, 'todos').then(function() { | ||
$scope.addTodo = function() { | ||
if (!$scope.newTodo.length) { | ||
return; | ||
} | ||
$scope.todos.push({ | ||
title: $scope.newTodo, | ||
completed: false | ||
}); | ||
$scope.newTodo = ''; | ||
}; | ||
$scope.removeTodo = function(todo) { | ||
$scope.todos.splice($scope.todos.indexOf(todo), 1); | ||
}; | ||
}); | ||
} | ||
|
||
function testIfInDOM(todo, node) { | ||
if (node.childNodes.length != 7) return false; | ||
if (node.childNodes[1].check != todo.completed) return false; | ||
if (node.childNodes[3].value != todo.title) return false; | ||
return true; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
|
||
var system = require('system'); | ||
casper.test.comment("Testing TODO example with implicit sync angularFire"); | ||
|
||
casper.test.comment('Testing TODO example with implicit sync angularFire'); | ||
casper.start("tests/test_todo.html", function() { | ||
// Sanity test for environment. | ||
this.test.assertTitle("AngularFire TODO Test"); | ||
this.test.assertEval(function() { | ||
if (!Firebase) return false; | ||
if (!AngularFire) return false; | ||
if (!_scope) return false; | ||
return true; | ||
}, "AngularFire exists"); | ||
}); | ||
|
||
casper.thenEvaluate(function() { | ||
// Clean up Firebase to start fresh test. | ||
var fbRef = new Firebase(_url); | ||
fbRef.set(null, function(err) { | ||
window.__flag = true; | ||
}); | ||
}); | ||
|
||
casper.start('file://' + system.env['ROOTDIR'] + '/examples/todomvc/index.html', function() { | ||
this.test.assertTitle('AngularJS • TodoMVC'); | ||
/* | ||
casper.then(function() { | ||
var _testTodo = { | ||
completed: false, | ||
title: "Eat some Chocolate" | ||
}; | ||
this.test.assertEval(function(todo) { | ||
_scope.newTodo = todo; | ||
_scope.addTodo(); | ||
return _scope.newTodo == ""; | ||
}, "Adding a new TODO", _testTodo); | ||
this.waitForSelector(".todoView", function() { | ||
this.test.assertEval(function(todo) { | ||
return testIfInDOM(todo, document.querySelector(".todoView")); | ||
}, "Testing if TODO is in the DOM", _testTodo); | ||
}); | ||
}); | ||
*/ | ||
|
||
casper.run(function() { | ||
this.test.done(1); | ||
this.test.done(); | ||
}); | ||
|