aboutsummaryrefslogtreecommitdiffstats
path: root/test/scenario/ApplicationSpec.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/ApplicationSpec.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/ApplicationSpec.js')
-rw-r--r--test/scenario/ApplicationSpec.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/scenario/ApplicationSpec.js b/test/scenario/ApplicationSpec.js
new file mode 100644
index 00000000..706fbc36
--- /dev/null
+++ b/test/scenario/ApplicationSpec.js
@@ -0,0 +1,75 @@
+describe('angular.scenario.Application', function() {
+ var app, frames;
+
+ beforeEach(function() {
+ frames = _jQuery("<div></div>");
+ app = new angular.scenario.Application(frames);
+ });
+
+ it('should return new $window and $document after navigate', function() {
+ var testWindow, testDocument, counter = 0;
+ app.navigateTo = noop;
+ app.getWindow = function() {
+ return {x:counter++, document:{x:counter++}};
+ };
+ app.navigateTo('http://www.google.com/');
+ app.executeAction(function($document, $window) {
+ testWindow = $window;
+ testDocument = $document;
+ });
+ app.navigateTo('http://www.google.com/');
+ app.executeAction(function($document, $window) {
+ expect($window).not.toEqual(testWindow);
+ expect($document).not.toEqual(testDocument);
+ });
+ });
+
+ it('should execute callback on $window of frame', function() {
+ var testWindow = {document: {}};
+ app.getWindow = function() {
+ return testWindow;
+ };
+ app.executeAction(function($document, $window) {
+ expect(this).toEqual($window);
+ expect(this).toEqual(testWindow);
+ });
+ });
+
+ it('should create a new iframe each time', function() {
+ app.navigateTo('about:blank');
+ var frame = app.getFrame();
+ frame.attr('test', true);
+ app.navigateTo('about:blank');
+ expect(app.getFrame().attr('test')).toBeFalsy();
+ });
+
+ it('should URL description bar', function() {
+ app.navigateTo('about:blank');
+ var anchor = frames.find('> h2 a');
+ expect(anchor.attr('href')).toEqual('about:blank');
+ expect(anchor.text()).toEqual('about:blank');
+ });
+
+ it('should call onload handler when frame loads', function() {
+ var called;
+ app.getFrame = function() {
+ // Mock a little jQuery
+ var result = {
+ remove: function() {
+ return result;
+ },
+ attr: function(key, value) {
+ return (!value) ? 'attribute value' : result;
+ },
+ load: function() {
+ called = true;
+ }
+ };
+ return result;
+ };
+ app.navigateTo('about:blank', function() {
+ called = true;
+ });
+ expect(called).toBeTruthy();
+ });
+});