incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwbro...@apache.org
Subject [37/48] git commit: Add deviceready event.
Date Wed, 01 Aug 2012 16:39:09 GMT
Add deviceready event.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/commit/6c11be85
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/tree/6c11be85
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/diff/6c11be85

Branch: refs/heads/master
Commit: 6c11be853db95f13a085330302fb47ee145eba4b
Parents: 5fe4752
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Thu Jul 12 22:12:59 2012 -0700
Committer: Michael Brooks <michael@michaelbrooks.ca>
Committed: Thu Jul 12 22:12:59 2012 -0700

----------------------------------------------------------------------
 www/js/index.js   |    5 +++++
 www/spec.html     |    1 +
 www/spec/index.js |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/blob/6c11be85/www/js/index.js
----------------------------------------------------------------------
diff --git a/www/js/index.js b/www/js/index.js
index 67f3ed4..5b89899 100644
--- a/www/js/index.js
+++ b/www/js/index.js
@@ -3,5 +3,10 @@ var app = {
         this.bind();
     },
     bind: function() {
+        document.addEventListener('deviceready', this.event.deviceready, false);
+    },
+    event: {
+        deviceready: function() {
+        }
     }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/blob/6c11be85/www/spec.html
----------------------------------------------------------------------
diff --git a/www/spec.html b/www/spec.html
index b123630..478fd77 100644
--- a/www/spec.html
+++ b/www/spec.html
@@ -10,6 +10,7 @@
         <script type="text/javascript" src="spec/lib/jasmine-1.2.0/jasmine-html.js"></script>
 
         <!-- include source files here... -->
+        <script type="text/javascript" src="spec/helper.js"></script>
         <script type="text/javascript" src="spec/index.js"></script>
 
         <!-- include spec files here... -->

http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/blob/6c11be85/www/spec/index.js
----------------------------------------------------------------------
diff --git a/www/spec/index.js b/www/spec/index.js
index 7d48350..63f7a29 100644
--- a/www/spec/index.js
+++ b/www/spec/index.js
@@ -14,4 +14,38 @@ describe('app', function() {
             expect(app.bind).toHaveBeenCalled();
         });
     });
+
+    describe('bind', function() {
+        it('should exist', function() {
+            expect(app.bind).toBeDefined();
+        });
+
+        describe('deviceready', function() {
+            it('should call app.event.deviceready on deviceready', function() {
+                runs(function() {
+                    spyOn(app.event, 'deviceready');
+                    app.bind();
+                    helper.trigger(window.document, 'deviceready');
+                });
+                waitsFor(function() {
+                    return (app.event.deviceready.calls.length > 0);
+                }, 'deviceready should be called once', 500);
+                runs(function() {
+                    expect(app.event.deviceready).toHaveBeenCalled();
+                });
+            });
+        });
+    });
+
+    describe('event', function() {
+        it('should exist', function() {
+            expect(app.event).toBeDefined();
+        });
+
+        describe('deviceready', function() {
+            it('should exist', function() {
+                expect(app.event.deviceready).toBeDefined();
+            });
+        });
+    });
 });


Mime
View raw message