Merge commit 'origin/master' into directives

This commit is contained in:
Adam Abrons 2010-03-16 10:34:46 -07:00
commit 34d48489d5
18 changed files with 293 additions and 30 deletions

7
.idea/.rakeTasks Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Settings><!--This file was automatically generated by Ruby plugin.
You are allowed to:
1. Remove rake task
2. Add existing rake tasks
To add existing rake tasks automatically delete this file and reload the project.
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Compile JavaScript" fullCmd="compile" taksId="compile" /><RakeTask description="Generate Externs" fullCmd="compileexterns" taksId="compileexterns" /><RakeTask description="Lint" fullCmd="lint" taksId="lint" /><RakeGroup description="" fullCmd="" taksId="server"><RakeTask description="Run JsTestDriver Server" fullCmd="server:start" taksId="start" /><RakeTask description="Run JavaScript tests against the server" fullCmd="server:test" taksId="test" /></RakeGroup><RakeTask description="Run JavaScript tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings>

5
.idea/encodings.xml Normal file
View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

9
.idea/master.iml Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RUBY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

14
.idea/misc.xml Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="ProjectDetails">
<option name="projectName" value="master" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Ruby SDK 1.8.7 (/usr/bin/ruby)" project-jdk-type="RUBY_SDK" />
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true" />
</component>
</project>

9
.idea/modules.xml Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/master.iml" filepath="$PROJECT_DIR$/.idea/master.iml" />
</modules>
</component>
</project>

8
.idea/vcs.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View file

@ -10,7 +10,8 @@
scope.set('a', 3);
scope.updateView();
});
</script> </head>
</script>
</head>
<body>
Quantity: <input type="text" name="a" value="2">
*

10
scenario/Runner.html Normal file
View file

@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="../src/scenario/bootstrap.js"></script>
<script type="text/javascript" src="widgets-scenarios.js"></script>
<script type="text/javascript" src="datastore-scenarios.js"></script>
</head>
<body>
</body>
</html>

View file

@ -0,0 +1,19 @@
angular.scenarioDef.datastore = {
$before:[
{Given:"dataset",
dataset:{
Book:[{$id:'moby', name:"Moby Dick"},
{$id:'gadsby', name:'Great Gadsby'}]
}
},
{Given:"browser", at:"datastore.html#book=moby"},
],
checkLoadBook:[
{Then:"drainRequestQueue"},
{Then:"text", at:"{{book.$id}}", should_be:"moby"},
{Then:"text", at:"li[$index=0] {{book.name}}", should_be:"Great Gahdsby"},
{Then:"text", at:"li[$index=0] {{book.name}}", should_be:"Moby Dick"},
]
};

17
scenario/datastore.html Normal file
View file

@ -0,0 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="../lib/underscore/underscore.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../src/angular-bootstrap.js"></script>
<script type="text/javascript">
$(document).ready(function(){angular.compile(document).init();});
</script>
</head>
<body ng-entity="book=Book" ng-init="books=Book.all()">
<p>{{book.$id}}</p>
<li ng-repeat="book in books.$orderBy('name')">
<li>{{book.name}}</li>
</li>
</body>
</html>

View file

@ -0,0 +1,49 @@
angular.scenarioDef.widgets = {
$before:[
{Given:"browser", at:"widgets.html"}
],
checkWidgetBinding:[
{Then:"text", at:"{{name}}", should_be:""},
{When:"enter", text:"John", at:":input[name=name]"},
{Then:"text", at:"{{name}}", should_be:"John"},
{Then:"text", at:"{{gender}}", should_be:""},
{When:"click", at:"input:radio[value=male]"},
{Then:"text", at:"{{gender}}", should_be:"male"},
{Then:"text", at:"{{tea}}", should_be:"on"},
{When:"click", at:"input[name=tea]"},
{Then:"text", at:"{{tea}}", should_be:""},
{Then:"text", at:"{{coffee}}", should_be:""},
{When:"click", at:"input[name=coffee]"},
{Then:"text", at:"{{coffee}}", should_be:"on"},
{Then:"text", at:"{{count}}", should_be:0},
{When:"click", at:"form :button"},
{When:"click", at:"form :submit"},
{When:"click", at:"form :image"},
{Then:"text", at:"{{count}}", should_be:3},
{Then:"text", at:"{{select}}", should_be:"A"},
{When:"select", at:"select[name=select]", option:"B"},
{Then:"text", at:"{{select}}", should_be:"B"},
{Then:"text", at:"{{multiple}}", should_be:"[]"},
{When:"select", at:"select[name=multiple]", option:"A"},
{Then:"text", at:"{{multiple}}", should_be:["A"]},
{When:"select", at:"select[name=multiple]", option:"B"},
{Then:"text", at:"{{multiple}}", should_be:["A", "B"]},
{When:"select", at:"select[name=multiple]", option:"A"},
{Then:"text", at:"{{multiple}}", should_be:["B"]},
{Then:"text", at:"{{hidden}}", should_be:"hiddenValue"},
{Then:"text", at:"{{password}}", should_be:"passwordValue"},
{When:"enter", text:"reset", at:":input[name=password]"},
{Then:"text", at:"{{password}}", should_be:"reset"},
],
checkNewWidgetEmpty:[
{Then:"text", at:"{{name}}", should_be:""},
]
};

58
scenario/widgets.html Normal file
View file

@ -0,0 +1,58 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="../lib/underscore/underscore.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../src/angular-bootstrap.js"></script>
<script type="text/javascript">
$(document).ready(function(){angular.compile(document).init();});
</script>
</head>
<body>
<p>
name: <input type="text" name="name" /> name={{name}} <br/>
</p>
<p>
<input type="radio" name="gender" value="female"/> Female
<input type="radio" name="gender" value="male"/> Male
gender={{gender}}
</p>
<p>
<input type="checkbox" name="tea" checked value="on"/> tea={{tea}} <br/>
<input type="checkbox" name="coffee" value="on"/> coffee={{coffee}} <br/>
</p>
<p ng-init="count = 0">
<form>
<input type="button" value="button" ng-action="count = count + 1"/>
<input type="submit" value="submit" ng-action="count = count + 1"/>
<input type="image" src="" ng-action="count = count + 1"/>
<a href="#ERROR" ng-action="count=count+1">action</a>
count={{count}}
</form>
</p>
<p>
<select name="select">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
select={{select}}
</p>
<p>
<select name="multiple" multiple>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
multiple={{multiple}}
</p>
<p>
<input type="hidden" name="hidden" value="hiddenValue" />
Hidden field = {{hidden}}
</p>
<p>
<input type="password" name="password" value="passwordValue" />
Password field = {{password}}
</p>
</body>
</html>

View file

@ -1,15 +1,16 @@
if (typeof test == 'undefined') test = {};
test.ScenarioRunner = function(scenarios, body) {
var scenario = angular.scenario;
scenario.SuiteRunner = function(scenarios, body) {
this.scenarios = scenarios;
this.body = body;
};
test.ScenarioRunner.prototype = {
scenario.SuiteRunner.prototype = {
run:function(){
this.setUpUI();
this.runScenarios();
},
setUpUI:function(){
this.body.html(
'<div id="runner">' +
@ -24,23 +25,25 @@ test.ScenarioRunner.prototype = {
jQuery(this).parent().find('.log').toggle();
});
},
runScenarios:function(){
var runner = new test.Runner(this.console, this.testFrame);
_.stepper(this.scenarios, function(next, scenario, name){
new test.Scenario(name, scenario).run(runner, next);
var runner = new scenario.Runner(this.console, this.testFrame);
_.stepper(this.scenarios, function(next, scenarioObj, name){
new scenario.Scenario(name, scenarioObj).run(runner, next);
}, function(){
}
);
}
};
test.Runner = function(console, frame){
scenario.Runner = function(console, frame){
this.console = console;
this.current = null;
this.tests = [];
this.frame = frame;
};
test.Runner.prototype = {
scenario.Runner.prototype = {
start:function(name){
var current = this.current = {
name:name,
@ -86,11 +89,11 @@ test.Runner.prototype = {
}
};
test.Scenario = function(name, scenario){
scenario.Scenario = function(name, scenario){
this.name = name;
this.scenario = scenario;
};
test.Scenario.prototype = {
scenario.Scenario.prototype = {
run:function(runner, callback) {
var self = this;
_.stepper(this.scenario, function(next, steps, name){
@ -108,16 +111,20 @@ test.Scenario.prototype = {
}
}, callback);
},
verb:function(step){
var fn = null;
if (!step) fn = function (){ throw "Step is null!"; };
else if (step.Given) fn = angular.test.GIVEN[step.Given];
else if (step.When) fn = angular.test.WHEN[step.When];
else if (step.Then) fn = angular.test.THEN[step.Then];
return fn || function (){
throw "ERROR: Need Given/When/Then got: " + toJson(step);
};
if (!step) fn = function (){ throw "Step is null!"; };
else if (step.Given) fn = scenario.GIVEN[step.Given];
else if (step.When) fn = scenario.WHEN[step.When];
else if (step.Then) fn = scenario.THEN[step.Then];
return fn || function (){
throw "ERROR: Need Given/When/Then got: " + toJson(step);
};
},
context: function(runner) {
var frame = runner.frame;
var window = frame[0].contentWindow;
@ -144,11 +151,13 @@ test.Scenario.prototype = {
};
return context;
},
executeStep:function(runner, step, callback) {
if (!step) {
callback();
return;
}
callback();
return;
}
runner.log("info", toJson(step));
var fn = this.verb(step);
var context = this.context(runner);

View file

@ -1,4 +1,4 @@
angular.test.GIVEN = {
angular.scenario.GIVEN = {
browser:function(){
var self = this;
if (jQuery.browser.safari && this.frame.attr('src') == this.at) {
@ -17,7 +17,7 @@ angular.test.GIVEN = {
this.frame.name="$DATASET:" + toJson({dataset:this.dataset});
}
};
angular.test.WHEN = {
angular.scenario.WHEN = {
enter:function(){
var element = this.element(this.at);
element.attr('value', this.text);
@ -40,7 +40,7 @@ angular.test.WHEN = {
element.change();
}
};
angular.test.THEN = {
angular.scenario.THEN = {
text:function(){
var element = this.element(this.at);
if (typeof this.should_be != undefined ) {

View file

@ -0,0 +1,6 @@
if (!angular) var angular = window['angular'] = {};
if (!angular['scenario']) var angularScenario = angular['scenario'] = {};
if (!angular['scenarioDef']) var scenarioDef = angular['scenarioDef'] = {};
if (!angular['scenario']['GIVEN']) angularScenario['GIVEN'] = {};
if (!angular['scenario']['WHEN']) angularScenario['WHEN'] = {};
if (!angular['scenario']['THEN']) angularScenario['THEN'] = {};

47
src/scenario/bootstrap.js vendored Normal file
View file

@ -0,0 +1,47 @@
(function(onLoadDelegate){
var prefix = (function(){
var filename = /(.*\/)bootstrap.js(#(.*))?/;
var scripts = document.getElementsByTagName("script");
for(var j = 0; j < scripts.length; j++) {
var src = scripts[j].src;
if (src && src.match(filename)) {
var parts = src.match(filename);
return parts[1];
}
}
})();
function addScript(path) {
document.write('<script type="text/javascript" src="' + prefix + path + '"></script>');
};
function addCSS(path) {
document.write('<link rel="stylesheet" type="text/css" href="' + prefix + path + '"/>');
};
window.onload = function(){
if (!_.stepper) {
_.stepper = function(collection, iterator, done){
var keys = _.keys(collection);
function next() {
if (keys.length) {
var key = keys.shift();
iterator(next, collection[key], key);
} else {
(done||_.identity)();
}
}
next();
};
}
_.defer(function(){
new angular.scenario.SuiteRunner(angular.scenarioDef, jQuery(document.body)).run();
});
(onLoadDelegate||function(){})();
};
addCSS("../../css/angular-scenario.css");
addScript("../../lib/underscore/underscore.js");
addScript("../../lib/jquery/jquery-1.3.2.js");
addScript("../angular-bootstrap.js");
addScript("_namespace.js");
addScript("Steps.js");
addScript("Runner.js");
})(window.onload);

View file

@ -1,5 +0,0 @@
if (!angular) var angular = window['angular'] = {};
if (!angular['test']) var angularTest = angular['test'] = {};
if (!angular['test']['GIVEN']) angularTest['GIVEN'] = {};
if (!angular['test']['WHEN']) angularTest['WHEN'] = {};
if (!angular['test']['THEN']) angularTest['THEN'] = {};