incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwbro...@apache.org
Subject [8/10] git commit: [test] Refactor tests to be generalized.
Date Tue, 17 Jul 2012 05:06:36 GMT
[test] Refactor tests to be generalized.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/6c162b39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/6c162b39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/6c162b39

Branch: refs/heads/hello-cordova
Commit: 6c162b39ef05dbdb348a9e766af7564e73d826cf
Parents: b18d442
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Fri Jul 13 16:40:19 2012 -0700
Committer: Michael Brooks <michael@michaelbrooks.ca>
Committed: Fri Jul 13 16:40:19 2012 -0700

----------------------------------------------------------------------
 www/js/index.js   |    8 ++---
 www/spec/index.js |   66 +++++++++++------------------------------------
 2 files changed, 19 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/6c162b39/www/js/index.js
----------------------------------------------------------------------
diff --git a/www/js/index.js b/www/js/index.js
index ce8d9b2..aa84f8c 100644
--- a/www/js/index.js
+++ b/www/js/index.js
@@ -3,12 +3,10 @@ var app = {
         this.bind();
     },
     bind: function() {
-        document.addEventListener('deviceready', this.event.deviceready, false);
+        document.addEventListener('deviceready', this.deviceready, false);
     },
-    event: {
-        deviceready: function() {
-            app.report('deviceready');
-        }
+    deviceready: function() {
+        app.report('deviceready');
     },
     report: function(id) {
         document.getElementById(id).innerHTML= 'ok';

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/6c162b39/www/spec/index.js
----------------------------------------------------------------------
diff --git a/www/spec/index.js b/www/spec/index.js
index 930fe85..74d9062 100644
--- a/www/spec/index.js
+++ b/www/spec/index.js
@@ -1,65 +1,31 @@
 describe('app', function() {
-    it('should exist', function() {
-        expect(app).toBeDefined();
-    });
-
     describe('initialize', function() {
-        it('should exist', function() {
-            expect(app.initialize).toBeDefined();
-        });
-
-        it('should bind events', function() {
-            spyOn(app, 'bind');
-            app.initialize();
-            expect(app.bind).toHaveBeenCalled();
-        });
-    });
+        it('should bind deviceready', function() {
+            runs(function() {
+                spyOn(app, 'deviceready');
+                app.initialize();
+                helper.trigger(window.document, 'deviceready');
+            });
 
-    describe('bind', function() {
-        it('should exist', function() {
-            expect(app.bind).toBeDefined();
-        });
+            waitsFor(function() {
+                return (app.deviceready.calls.length > 0);
+            }, 'deviceready should be called once', 500);
 
-        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();
-                });
+            runs(function() {
+                expect(app.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();
-            });
-
-            it('should report that it fired', function() {
-                spyOn(app, 'report');
-                app.event.deviceready();
-                expect(app.report).toHaveBeenCalledWith('deviceready');
-            });
+    describe('deviceready', function() {
+        it('should report that it fired', function() {
+            spyOn(app, 'report');
+            app.deviceready();
+            expect(app.report).toHaveBeenCalledWith('deviceready');
         });
     });
 
     describe('report', function() {
-        it('should exist', function() {
-            expect(app.report).toBeDefined();
-        });
-
         it('should report "ok" for the given ID', function() {
             document.getElementById('stage').innerHTML = '<span id="deviceready"></span>';
             app.report('deviceready');


Mime
View raw message