aboutsummaryrefslogtreecommitdiffstats
path: root/test/scenario/matchersSpec.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 /test/scenario/matchersSpec.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 'test/scenario/matchersSpec.js')
-rw-r--r--test/scenario/matchersSpec.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/scenario/matchersSpec.js b/test/scenario/matchersSpec.js
new file mode 100644
index 00000000..faabd1a2
--- /dev/null
+++ b/test/scenario/matchersSpec.js
@@ -0,0 +1,43 @@
+describe('angular.scenario.matchers', function () {
+ var matchers;
+
+ function expectMatcher(value, test) {
+ delete matchers.error;
+ delete matchers.future.value;
+ if (value !== undefined) {
+ matchers.future.value = value;
+ }
+ test();
+ expect(matchers.error).toBeUndefined();
+ }
+
+ beforeEach(function() {
+ /**
+ * Mock up the future system wrapped around matchers.
+ *
+ * @see Scenario.js#angular.scenario.matcher
+ */
+ matchers = {
+ future: { name: 'test' }
+ };
+ matchers.addFuture = function(name, callback) {
+ callback(function(error) {
+ matchers.error = error;
+ });
+ };
+ angular.extend(matchers, angular.scenario.matcher);
+ });
+
+ it('should handle basic matching', function() {
+ expectMatcher(10, function() { matchers.toEqual(10); });
+ expectMatcher('value', function() { matchers.toBeDefined(); });
+ expectMatcher([1], function() { matchers.toBeTruthy(); });
+ expectMatcher("", function() { matchers.toBeFalsy(); });
+ expectMatcher(0, function() { matchers.toBeFalsy(); });
+ expectMatcher('foo', function() { matchers.toMatch('.o.'); });
+ expectMatcher(null, function() { matchers.toBeNull(); });
+ expectMatcher([1, 2, 3], function() { matchers.toContain(2); });
+ expectMatcher(3, function() { matchers.toBeLessThan(10); });
+ expectMatcher(3, function() { matchers.toBeGreaterThan(-5); });
+ });
+});