Commit ee537451 authored by asudoh's avatar asudoh

Removed test files from dojo18 branch.

parent bf4f1975
This diff is collapsed.
define([
"doh",
"dojo/json",
"dojox/mvc/at",
"../../ctrl/TodoListRefController",
"../../ctrl/TodoRefController",
"../../model/SimpleTodoModel",
"../../store/LocalStorage"
], function(doh, json, at, TodoListRefController, TodoRefController, SimpleTodoModel, LocalStorage){
doh.register("todo.tests.ctrl.TodoListRefController", [
function empty(){
localStorage.removeItem("todos-dojo");
var ctrl = new TodoRefController({
defaultId: "todos-dojo",
modelClass: SimpleTodoModel,
store: new LocalStorage()
}), listCtrl = new TodoListRefController({
model: at(ctrl, "todos")
});
doh.is(0, ctrl.get("complete"), "The current count of completed todo items should be 0");
doh.is(0, ctrl.get("incomplete"), "The current count of incomplete todo items should be 0");
doh.is(0, listCtrl.get("length"), "The current length should be 0");
listCtrl.model.push({title: "Task0", completed: false});
doh.is(0, ctrl.get("complete"), "The current count of completed todo items should be 0");
doh.is(1, ctrl.get("incomplete"), "The current count of incomplete todo items should be 1");
doh.is(1, listCtrl.get("length"), "The current length should be 1");
},
function existing(){
localStorage.setItem("todos-dojo", json.stringify({
id: "todos-dojo",
todos : [
{title: "Task0", completed: false},
{title: "Task1", completed: true},
{title: "Task2", completed: false}
],
incomplete: 2,
complete: 1
}));
var ctrl = new TodoRefController({
defaultId: "todos-dojo",
modelClass: SimpleTodoModel,
store: new LocalStorage()
}), listCtrl = new TodoListRefController({
model: at(ctrl, "todos")
});
doh.is(1, ctrl.get("complete"), "The current count of completed todo items should be 1");
doh.is(2, ctrl.get("incomplete"), "The current count of incomplete todo items should be 2");
doh.is(3, listCtrl.get("length"), "The current length should be 3");
}
]);
});
\ No newline at end of file
(function(require){
require.baseUrl = "../../dojo";
require.packages = (require.packages || []).concat([{
name: "todo",
location: "../todomvc/architecture-examples/dojo/js/todo"
}]);
})(require);
define([
"doh",
"dojo/Stateful",
"../../model/SimpleTodoModel"
], function(doh, Stateful, SimpleTodoModel){
doh.register("todo.tests.model.SimpleTodoModel", [
function basic(){
var model = new SimpleTodoModel({
id: "todos-dojo",
todos : [
{title: "Task0", completed: false},
{title: "Task1", completed: true},
{title: "Task2", completed: false}
],
incomplete: 2,
complete: 1
});
model.todos.push(new Stateful({title: "Task3", completed: true}), new Stateful({title: "Task4", completed: false}));
doh.is(2, model.complete, "We should have two complete tasks");
doh.is(3, model.incomplete, "We should have three incomplete tasks");
model.todos.push(new Stateful({title: "Task5", completed: false}));
doh.is(2, model.complete, "We should have two complete tasks");
doh.is(4, model.incomplete, "We should have four incomplete tasks");
model.todos[4].set("completed", true);
doh.is(3, model.complete, "We should have three complete tasks");
doh.is(3, model.incomplete, "We should have three incomplete tasks");
model.todos.splice(4, 1);
doh.is(2, model.complete, "We should have two complete tasks");
doh.is(3, model.incomplete, "We should have three incomplete tasks");
}
]);
});
\ No newline at end of file
define([
"doh",
"./ctrl/TodoListRefController",
"./model/SimpleTodoModel"
], function(doh){
var userArgs = window.location.search.replace(/[\?&](dojoUrl|testUrl|testModule)=[^&]*/g, "").replace(/^&/, "?");
doh.registerUrl("todo.tests.app18", require.toUrl("todo/tests/app18.html") + userArgs, 999999);
});
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
This is a test runner for Dojo version of TodoMVC.
To use this, place todomvc directory at the directory containing dojo/dijit/dojox.
-->
<html>
<head>
<title>Unit Test Runner</title>
<script>
function onLoadHandler(){
var queryString = window.location.search.substr(1), queries = queryString.split("&"), moduleFound = false;
for(var i = 0; i < queries.length; i++){
if(/^test(|Url|Module)=/i.test(queries[i])){
moduleFound = true;
break;
}
}
if(!moduleFound){
queryString += (queryString ? "&" : "") + "test=todo/tests/module&async=true";
}
document.getElementById("testFrame").src = "../../../../../../util/doh/runner.html?boot=../../todomvc/architecture-examples/dojo/js/todo/tests/dojoConfig.js" + (queryString ? ("&" + queryString) : "");
}
function iFrameOnLoadHandler(){
// summary:
// Makes sure todo/tests/dojoConfig.js is loaded before dojo.js is loaded.
// DOH's &boot URL arg handler does not allow us to specify what order the modules are loaded.
var w = document.getElementById("testFrame").contentWindow, found = false;
for(var packs = (w.require || {}).packages, i = 0; packs && i < packs.length; i++){
if(packs[i].name == "todo"){
found = true;
break;
}
}
if(!found){
return setTimeout(iFrameOnLoadHandler, 500);
}
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "../../../../../../dojo/dojo.js";
script.charset = "utf-8";
w.document.getElementsByTagName("head")[0].appendChild(script);
}
</script>
</head>
<body onload="onLoadHandler();" style="width:100%;height:100%;margin:0;padding:0;">
<iframe id="testFrame" onload="iFrameOnLoadHandler();" frameborder="0" style="width:100%;height:100%;margin:0;padding:0;"></iframe>
</body>
</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