cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtan...@apache.org
Subject [1/16] js commit: Updates to tests and pulled updates from Gord Tanner
Date Tue, 13 Nov 2012 19:13:42 GMT
Updated Branches:
  refs/heads/master 1fd563856 -> 74f47a649


Updates to tests and pulled updates from Gord Tanner

Pulled updates from Gord and with his help updated a bunch of the tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/74f47a64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/74f47a64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/74f47a64

Branch: refs/heads/master
Commit: 74f47a64986327971b1d394fbb5ec24d471d951a
Parents: fc85e82 46f7216
Author: Matt Lantz <malantz@rim.com>
Authored: Tue Nov 13 14:05:36 2012 -0500
Committer: Matt Lantz <malantz@rim.com>
Committed: Tue Nov 13 14:05:36 2012 -0500

----------------------------------------------------------------------
 lib/blackberry/platform.js                         |    9 +-
 lib/blackberry/plugin/webworks/accelerometer.js    |    2 +-
 lib/blackberry/plugin/webworks/media.js            |    6 +-
 lib/windowsphone/plugin/windowsphone/DOMStorage.js |    4 +-
 test/blackberry/test.platform.js                   |   31 +-
 test/blackberry/webworks/test.accelerometer.js     |   72 ++-
 test/blackberry/webworks/test.logger.js            |   22 +-
 test/blackberry/webworks/test.media.js             |  435 ++++++++-------
 test/blackberry/webworks/test.notification.js      |   76 ++--
 test/suite.html                                    |    2 +
 10 files changed, 362 insertions(+), 297 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/74f47a64/test/blackberry/webworks/test.accelerometer.js
----------------------------------------------------------------------
diff --cc test/blackberry/webworks/test.accelerometer.js
index b315108,10af041..860ccc4
--- a/test/blackberry/webworks/test.accelerometer.js
+++ b/test/blackberry/webworks/test.accelerometer.js
@@@ -20,28 -20,51 +20,52 @@@
  */
  
  describe("accelerometer", function () {
-     var accelerometer = require('cordova/plugin/webworks/accelerometer');
+     var accelerometer = require('cordova/plugin/webworks/accelerometer'),
+         cordova = require('cordova');
  
-     describe("start", function() {
-         it("should start webworks watching the accelerometer", function() {            
-             spyOn(window, "removeEventListener");
-             spyOn(window, "addEventListener");
+     beforeEach(function(){
+         spyOn(window, "removeEventListener");
+         spyOn(window, "addEventListener");
+     });
  
-             var win = jasmine.createSpy('win'),
-                 fail = jasmine.createSpy('fail'),
-                 args = {x:1,y:2,z:3},
-                 aStart = accelerometer.start(args, win, fail);
+     describe("start", function() {
+         it("returns no result", function () {
+             expect(accelerometer.start()).toEqual({
+                 status: cordova.callbackStatus.NO_RESULT,
+                 message: "WebWorks Is On It"
+             });
+         });
  
-             expect(window.removeEventListener).toHaveBeenCalledWith("devicemotion", undefined);
+         it("removes the event listener", function () {
+             accelerometer.start();
+             expect(window.removeEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function));
+         });
  
+         it("adds the event listener back", function () {
+             accelerometer.start();
              expect(window.addEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function));
+         });
  
-             window.removeEventListener.reset();
-             window.addEventListener.reset();
-         	
-             expect(aStart.status).toBe(0);
-         	expect(aStart.message).toBe('WebWorks Is On It');
+         it("grabs the motion information from the callback and calls success", function
() {
+             var success = jasmine.createSpy("success");
+             accelerometer.start({}, success);
+ 
+             window.addEventListener.mostRecentCall.args[1]({
+                 accelerationIncludingGravity: {
+                     x: 1,
+                     y: 2,
+                     z: 3,
+                 },
+                 timestamp: "around tea time"
+             });
+ 
+             expect(success).toHaveBeenCalledWith({
+                 x: 1,
+                 y: 2,
+                 z: 3,
+                 timestamp: "around tea time"
+             });
 +
          });
      });
  

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/74f47a64/test/blackberry/webworks/test.notification.js
----------------------------------------------------------------------
diff --cc test/blackberry/webworks/test.notification.js
index a3375dd,a3375dd..684aca2
--- a/test/blackberry/webworks/test.notification.js
+++ b/test/blackberry/webworks/test.notification.js
@@@ -20,15 -20,15 +20,16 @@@
  */
  
  describe("notification", function () {
--    var notification = require('cordova/plugin/webworks/notification');
++    var notification = require('cordova/plugin/webworks/notification'),
++        cordova = require('cordova');
  
      beforeEach(function(){
          global.blackberry = {
              ui:{
                  dialog:{
--                    customAskAsync: {
--                        apply: function(args){ return args; }
--                    }
++                    customAskAsync: jasmine.createSpy()
++                        // apply: jasmine.createSpy('apply')
++                    
                  }
              }
          }
@@@ -38,50 -38,50 +39,49 @@@
          delete global.blackberry;
      });
  
--    describe("alert - arguments not equal to three", function() {
--        it("should provide an alert notification", function() {            
++    describe("alert", function() {
  
--            var args = "Danger, danger Will Robinson!",
--                n = notification.alert(args);
--
--            expect(args.length).not.toBe(3);
--        	expect(n.status).toBe(9);
--        	expect(n.message).toBe('Notification action - alert arguments not found');
++        it("should return that alert arguments are missing", function() {
++            expect(notification.alert("")).toEqual({
++                status: 9,
++                message: "Notification action - alert arguments not found"
++            });
          });
--    });
--
--    describe("alert - arguments equal to three", function() {
--        it("should call a webworks action", function() { 
--            
--            var n = notification.alert(["Danger, danger Will Robinson", "Panic, is my middle
name", "PANIC"]);
--
--            expect(n.status).toBe(0);
--            expect(n.message).toBe('WebWorks Is On It');
  
++        it("should call the blackberry object", function() {
++            var win = jasmine.createSpy('win'); 
++            notification.alert(["Danger, danger Will Robinson!", "Panic, is my middle name",
"PANIC!"], win);
++            expect(blackberry.ui.dialog.customAskAsync).toHaveBeenCalledWith("Danger, danger
Will Robinson!", [ "PANIC!" ], win, { "title" : "Panic, is my middle name" });
++        });
++        
++        it("should return that WebWorks Is On It", function() {
++            expect(notification.alert(["Danger, danger Will Robinson!", "Panic, is my middle
name", "PANIC!"])).toEqual({
++                status: cordova.callbackStatus.NO_RESULT,
++                message: "WebWorks Is On It"
++            });
          });
      });
  
--    describe("confirm - arguments not equal to three", function() {
--        it("should provide a confirm notification", function() {            
++    describe("confirm", function() {
++        it("should return that alert arguments are missing", function() {
++            expect(notification.confirm("")).toEqual({
++                status: 9,
++                message: "Notification action - confirm arguments not found"
++            });
++        });
  
--            var args = "Are you sure you're ready to jump?",
--                n = notification.confirm(args);
++        it("should call the blackberry object", function() {
++            var win = jasmine.createSpy('win'); 
++            notification.confirm(["Are you interested in cheaper long distance?", "Serving
you better!", "SCREAM,CONFIRM"], win);
  
--            expect(args.length).not.toBe(3);
--            expect(n.status).toBe(9);
--            expect(n.message).toBe('Notification action - confirm arguments not found');
++            expect(blackberry.ui.dialog.customAskAsync).toHaveBeenCalledWith("Are you interested
in cheaper long distance?", [ "SCREAM", "CONFIRM" ], win, { "title" : "Serving you better!"
});
          });
--    });
--
--    // confirm handled by webworks
--    describe("alert - arguments equal to three", function() {
--        it("should call a webworks action", function() {            
          
--            var n = notification.confirm(["Danger, danger Will Robinson", "Panic, is my
middle name", "PANIC"]);
--            
--            expect(n.status).toBe(0);
--            expect(n.message).toBe('WebWorks Is On It');
--
++        it("should return that WebWorks Is On It", function() {
++            expect(notification.confirm(["Danger, danger Will Robinson!", "Panic, is my
middle name", "PANIC!"])).toEqual({
++                status: cordova.callbackStatus.NO_RESULT,
++                message: "WebWorks Is On It"
++            });
          });
      });
  


Mime
View raw message