aboutsummaryrefslogtreecommitdiffstats
path: root/src/scenario/Future.js
diff options
context:
space:
mode:
authorElliott Sprehn2010-10-08 16:43:40 -0700
committerElliott Sprehn2010-10-14 09:47:39 -0700
commit03df6cbddbb80186caf571e29957370b2ef9881c (patch)
treed5a321c8b207b464a5c8a300c422186e20e8ae31 /src/scenario/Future.js
parent0f104317dff5628765e26cc68df7dd1175b2aa5e (diff)
downloadangular.js-03df6cbddbb80186caf571e29957370b2ef9881c.tar.bz2
New Angular Scenario runner and DSL system with redesigned HTML UI.
Uses the Jasmine syntax for tests, ex: describe('widgets', function() { it('should verify that basic widgets work', function(){ navigateTo('widgets.html'); input('text.basic').enter('Carlos'); expect(binding('text.basic')).toEqual('Carlos'); input('text.basic').enter('Carlos Santana'); expect(binding('text.basic')).not().toEqual('Carlos Boozer'); input('text.password').enter('secret'); expect(binding('text.password')).toEqual('secret'); expect(binding('text.hidden')).toEqual('hiddenValue'); expect(binding('gender')).toEqual('male'); input('gender').select('female'); expect(binding('gender')).toEqual('female'); }); }); Note: To create new UI's implement the interface shown in angular.scenario.ui.Html.
Diffstat (limited to 'src/scenario/Future.js')
-rw-r--r--src/scenario/Future.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/scenario/Future.js b/src/scenario/Future.js
index cc40eff0..60fad9c5 100644
--- a/src/scenario/Future.js
+++ b/src/scenario/Future.js
@@ -1,13 +1,22 @@
-function Future(name, behavior) {
+/**
+ * A future action in a spec.
+ */
+angular.scenario.Future = function(name, behavior) {
this.name = name;
this.behavior = behavior;
this.fulfilled = false;
- this.value = _undefined;
-}
+ this.value = undefined;
+};
-Future.prototype = {
- fulfill: function(value) {
+/**
+ * Executes the behavior of the closure.
+ *
+ * @param {Function} Callback function(error, result)
+ */
+angular.scenario.Future.prototype.execute = function(doneFn) {
+ this.behavior(angular.bind(this, function(error, result) {
this.fulfilled = true;
- this.value = value;
- }
+ this.value = error || result;
+ doneFn(error, result);
+ }));
};