incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [10/16] changed test project to use updated tests + jasmine
Date Fri, 20 Apr 2012 21:33:30 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d62a7909/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js
index 7890b40..718d582 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/geolocation.tests.js
@@ -1,90 +1,100 @@
-Tests.prototype.GeoLocationTests = function() {	
-	module('Geolocation (navigator.geolocation)');
-	test("should exist", function() {
-  		expect(1);
-  		ok(navigator.geolocation != null, "navigator.geolocation should not be null.");
+describe('Geolocation (navigator.geolocation)', function () {
+	it("should exist", function() {
+        expect(navigator.geolocation).toBeDefined();
 	});
-	test("should contain a getCurrentPosition function", function() {
-		expect(2);
-		ok(typeof navigator.geolocation.getCurrentPosition != 'undefined' && navigator.geolocation.getCurrentPosition
!= null, "navigator.geolocation.getCurrentPosition should not be null.");
-		ok(typeof navigator.geolocation.getCurrentPosition == 'function', "navigator.geolocation.getCurrentPosition
should be a function.");
+
+	it("should contain a getCurrentPosition function", function() {
+		expect(typeof navigator.geolocation.getCurrentPosition).toBeDefined();
+		expect(typeof navigator.geolocation.getCurrentPosition == 'function').toBe(true);
 	});
-	test("should contain a watchPosition function", function() {
-		expect(2);
-		ok(typeof navigator.geolocation.watchPosition != 'undefined' && navigator.geolocation.watchPosition
!= null, "navigator.geolocation.watchPosition should not be null.");
-		ok(typeof navigator.geolocation.watchPosition == 'function', "navigator.geolocation.watchPosition
should be a function.");
+
+	it("should contain a watchPosition function", function() {
+		expect(typeof navigator.geolocation.watchPosition).toBeDefined();
+		expect(typeof navigator.geolocation.watchPosition == 'function').toBe(true);
 	});
-	test("should contain a clearWatch function", function() {
-		expect(2);
-		ok(typeof navigator.geolocation.clearWatch != 'undefined' && navigator.geolocation.clearWatch
!= null, "navigator.geolocation.watchPosition should not be null.");
-		ok(typeof navigator.geolocation.clearWatch == 'function', "navigator.geolocation.clearWatch
should be a function.");
+
+	it("should contain a clearWatch function", function() {
+		expect(typeof navigator.geolocation.clearWatch).toBeDefined();
+		expect(typeof navigator.geolocation.clearWatch == 'function').toBe(true);
 	});
-	test("getCurrentPosition success callback should be called with a Position object", function()
{
-		expect(2);
-		QUnit.stop(15000);
-		var win = function(p) {
-			ok(p.coords != null, "Position object returned in getCurrentPosition success callback
has a 'coords' property.");
-			ok(p.timestamp != null, "Position object returned in getCurrentPosition success callback
has a 'timestamp' property.");
-			QUnit.start();
-		};
-		var fail = function() { 
-        ok(false, "Error callback fired, test failed.");
-        QUnit.start();
-    };
-		navigator.geolocation.getCurrentPosition(win, fail, {
-        maximumAge:300000 // 5 minutes maximum age of cached position
-    });
+
+	it("getCurrentPosition success callback should be called with a Position object", function()
{
+		var win = jasmine.createSpy().andCallFake(function(a) {
+                expect(p.coords).not.toBe(null);
+                expect(p.timestamp).not.toBe(null);
+            }),
+            fail = jasmine.createSpy();
+
+        runs(function () {
+            navigator.geolocation.getCurrentPosition(win, fail, {
+                maximumAge:300000 // 5 minutes maximum age of cached position
+            });
+        });
+
+        waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+        runs(function () {
+            expect(fail).not.toHaveBeenCalled();
+        });
 	});
-  test("getCurrentPosition success callback should be called with a cached Position", function()
{
-    expect(1);
-    QUnit.stop(Tests.TEST_TIMEOUT);
-    var win = function(p) {
-      ok(p.coords instanceof Position, "Position object returned is an instance of Position");
-      QUnit.start();
-    };
-    var fail = function(e) {
-      ok(false, "Error callback called, test failed.");
-    };
-    navigator.geolocation.getCurrentPosition(win, fail, {
-        maximumAge:300000 // 5 minutes
-    });
-  });
-  test("getCurrentPosition error callback should be called if we set timeout to 0 and maximumAge
to a very small number", function() {
-    expect(1);
-    QUnit.stop(Tests.TEST_TIMEOUT);
-    var win = function(p) {
-      ok(false, "success callback called, test failed.");
-      QUnit.start();
-    };
-    var fail = function(e) {
-      ok(true, "error callback called");
-      QUnit.start();
-    };
-    navigator.geolocation.getCurrentPosition(win, fail, {
-        maximumAge: 0,
-        timeout: 0
+
+	it("getCurrentPosition success callback should be called with a cached Position", function()
{
+		var win = jasmine.createSpy().andCallFake(function(a) {
+                expect(p.coords instanceof Position).toBe(true);
+            }),
+            fail = jasmine.createSpy();
+
+        runs(function () {
+            navigator.geolocation.getCurrentPosition(win, fail, {
+                maximumAge:300000 // 5 minutes 
+            });
+        });
+
+        waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+        runs(function () {
+            expect(fail).not.toHaveBeenCalled();
+        });
+	});
+
+    it("getCurrentPosition error callback should be called if we set timeout to 0 and maximumAge
to a very small number", function() {
+        var win = jasmine.createSpy(),
+            fail = jasmine.createSpy();
+
+        runs(function () {
+            navigator.geolocation.getCurrentPosition(win, fail, {
+                maximumAge: 0,
+                timeout: 0
+            });
+        });
+
+        waitsFor(function () { return fail.wasCalled; }, "fail never called", Tests.TEST_TIMEOUT);
+
+        runs(function () {
+            expect(win).not.toHaveBeenCalled();
+        });
     });
-  });
+
 	// TODO: Need to test error callback... how?
 	// TODO: Need to test watchPosition success callback, test that makes sure clearPosition
works (how to test that a timer is getting cleared?)
-	module('Geolocation model');
-	test("should be able to define a Position object with coords and timestamp properties",
function() {
-		expect(3);
-		var pos = new Position({}, new Date());
-		ok(pos != null, "new Position() should not be null.");
-		ok(typeof pos.coords != 'undefined' && pos.coords != null, "new Position() should
include a 'coords' property.");
-		ok(typeof pos.timestamp != 'undefined' && pos.timestamp != null, "new Position()
should include a 'timestamp' property.");
-	});
-	test("should be able to define a Coordinates object with latitude, longitude, accuracy,
altitude, heading, speed and altitudeAccuracy properties", function() {
-		expect(8);
-		var coords = new Coordinates(1,2,3,4,5,6,7);
-		ok(coords != null, "new Coordinates() should not be null.");
-		ok(typeof coords.latitude != 'undefined' && coords.latitude != null, "new Coordinates()
should include a 'latitude' property.");
-		ok(typeof coords.longitude != 'undefined' && coords.longitude != null, "new Coordinates()
should include a 'longitude' property.");
-		ok(typeof coords.accuracy != 'undefined' && coords.accuracy != null, "new Coordinates()
should include a 'accuracy' property.");
-		ok(typeof coords.altitude != 'undefined' && coords.altitude != null, "new Coordinates()
should include a 'altitude' property.");
-		ok(typeof coords.heading != 'undefined' && coords.heading != null, "new Coordinates()
should include a 'heading' property.");
-		ok(typeof coords.speed != 'undefined' && coords.speed != null, "new Coordinates()
should include a 'speed' property.");
-		ok(typeof coords.altitudeAccuracy != 'undefined' && coords.altitudeAccuracy !=
null, "new Coordinates() should include a 'altitudeAccuracy' property.");
-	});
-};
+    describe("Geolocation model", function () {
+        it("should be able to define a Position object with coords and timestamp properties",
function() {
+            var pos = new Position({}, new Date());
+            expect(pos).toBeDefined();
+            expect(pos.coords).toBeDefined();
+            expect(pos.timestamp).toBeDefined();
+        });
+
+        it("should be able to define a Coordinates object with latitude, longitude, accuracy,
altitude, heading, speed and altitudeAccuracy properties", function() {
+            var coords = new Coordinates(1,2,3,4,5,6,7);
+            expect(coords).toBeDefined();
+            expect(coords.latitude).toBeDefined();
+            expect(coords.longitude).toBeDefined();
+            expect(coords.accuracy).toBeDefined();
+            expect(coords.altitude).toBeDefined();
+            expect(coords.heading).toBeDefined();
+            expect(coords.speed).toBeDefined();
+            expect(coords.altitudeAccuracy).toBeDefined();
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d62a7909/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js
index cf6ded4..d0e6c4f 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/media.tests.js
@@ -1,152 +1,144 @@
-Tests.prototype.MediaTests = function() {	
-	module('Media');
-	test("should exist", function() {
-  		expect(1);
-		ok(typeof Media === "function" || typeof Media === "object", "'Media' should be defined
as a function in global scope.");
+describe('Media', function () {
+	it("should exist", function() {
+        expect(Media).toBeDefined();
+		expect(typeof Media).toBe("function");
 	});
-    test("should have the following properties", function() {
+
+    it("should have the following properties", function() {
         var media1 = new Media("dummy");
-        expect(4);
-        ok(typeof media1.id != 'undefined' && media1.id != null, "'Media' should
have an id property.");
-        ok(typeof media1.src != 'undefined', "'Media' should have an src property.");
-        ok(typeof media1._duration != 'undefined' && media1._duration != null, "'Media'
should have an _duration property.");
-        ok(typeof media1._position != 'undefined' && media1._position != null, "'Media'
should have an _position property.");
+        expect(media1.id).toBeDefined();
+        expect(media1.src).toBeDefined();
+        expect(media1._duration).toBeDefined();
+        expect(media1._position).toBeDefined();
         media1.release();
     });
-	test("should define constants for Media errors", function() {
-		expect(6);
-		ok(MediaError != null && typeof MediaError != 'undefined', "MediaError object exists
in global scope.");
-        equals(MediaError.MEDIA_ERR_NONE_ACTIVE, 0, "MediaError.MEDIA_ERR_NONE_ACTIVE is
equal to 0.");
-        equals(MediaError.MEDIA_ERR_ABORTED, 1, "MediaError.MEDIA_ERR_ABORTED is equal to
1.");
-		equals(MediaError.MEDIA_ERR_NETWORK, 2, "MediaError.MEDIA_ERR_NETWORK is equal to 2.");
-		equals(MediaError.MEDIA_ERR_DECODE, 3, "MediaError.MEDIA_ERR_DECODE is equal to 3.");
-		equals(MediaError.MEDIA_ERR_NONE_SUPPORTED, 4, "MediaError.MEDIA_ERR_NONE_SUPPORTED is
equal to 4.");
+
+	it("should define constants for Media errors", function() {
+        expect(MediaError).toBeDefined();
+        expect(MediaError.MEDIA_ERR_NONE_ACTIVE).toBe(0);
+        expect(MediaError.MEDIA_ERR_ABORTED).toBe(1);
+		expect(MediaError.MEDIA_ERR_NETWORK).toBe(2);
+		expect(MediaError.MEDIA_ERR_DECODE).toBe(3);
+		expect(MediaError.MEDIA_ERR_NONE_SUPPORTED).toBe(4);
 	});
-    test("should contain a play function", function() {
+
+    it("should contain a play function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.play != 'undefined' && media1.play != null, "Media.play
should not be null.");
-        ok(typeof media1.play == 'function', "Media.play should be a function.");
+        expect(media1.play).toBeDefined();
+        expect(typeof media1.play).toBe('function');
         media1.release();
     });
-    test("should contain a stop function", function() {
+
+    it("should contain a stop function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.stop != 'undefined' && media1.stop != null, "Media.stop
should not be null.");
-        ok(typeof media1.stop == 'function', "Media.stop should be a function.");
+        expect(media1.stop).toBeDefined();
+        expect(typeof media1.stop).toBe('function');
         media1.release();
     });
-    test("should contain a seekTo function", function() {
+
+    it("should contain a seekTo function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.seekTo != 'undefined' && media1.seekTo != null, "Media.seekTo
should not be null.");
-        ok(typeof media1.seekTo == 'function', "Media.seekTo should be a function.");
+        expect(media1.seekTo).toBeDefined();
+        expect(typeof media1.seekTo).toBe('function');
         media1.release();
     });
-    test("should contain a pause function", function() {
+
+    it("should contain a pause function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.pause != 'undefined' && media1.pause != null, "Media.pause
should not be null.");
-        ok(typeof media1.pause == 'function', "Media.pause should be a function.");
+        expect(media1.pause).toBeDefined();
+        expect(typeof media1.pause).toBe('function');
         media1.release();
     });
-    test("should contain a getDuration function", function() {
+
+    it("should contain a getDuration function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.getDuration != 'undefined' && media1.getDuration != null,
"Media.getDuration should not be null.");
-        ok(typeof media1.getDuration == 'function', "Media.getDuration should be a function.");
+        expect(media1.getDuration).toBeDefined();
+        expect(typeof media1.getDuration).toBe('function');
         media1.release();
     });
-    test("should contain a getCurrentPosition function", function() {
+
+    it("should contain a getCurrentPosition function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.getCurrentPosition != 'undefined' && media1.getCurrentPosition
!= null, "Media.getCurrentPosition should not be null.");
-        ok(typeof media1.getCurrentPosition == 'function', "Media.getCurrentPosition should
be a function.");
+        expect(media1.getCurrentPosition).toBeDefined();
+        expect(typeof media1.getCurrentPosition).toBe('function');
         media1.release();
     });
-    test("should contain a startRecord function", function() {
+
+    it("should contain a startRecord function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.startRecord != 'undefined' && media1.startRecord != null,
"Media.startRecord should not be null.");
-        ok(typeof media1.startRecord == 'function', "Media.startRecord should be a function.");
+        expect(media1.startRecord).toBeDefined();
+        expect(typeof media1.startRecord).toBe('function');
         media1.release();
     });
-    test("should contain a stopRecord function", function() {
+
+    it("should contain a stopRecord function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.stopRecord != 'undefined' && media1.stopRecord != null,
"Media.stopRecord should not be null.");
-        ok(typeof media1.stopRecord == 'function', "Media.stopRecord should be a function.");
+        expect(media1.stopRecord).toBeDefined();
+        expect(typeof media1.stopRecord).toBe('function');
         media1.release();
     });
-    test("should contain a release function", function() {
+
+    it("should contain a release function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.release != 'undefined' && media1.release != null, "Media.release
should not be null.");
-        ok(typeof media1.release == 'function', "Media.release should be a function.");
+        expect(media1.release).toBeDefined();
+        expect(typeof media1.release).toBe('function');
         media1.release();
     });
-    test("should contain a setVolume function", function() {
+
+    it("should contain a setVolume function", function() {
         var media1 = new Media();
-        expect(2);
-        ok(typeof media1.setVolume != 'undefined' && media1.setVolume != null, "Media.setVolume
should not be null.");
-        ok(typeof media1.setVolume == 'function', "Media.setVolume should be a function.");
+        expect(media1.setVolume).toBeDefined();
+        expect(typeof media1.setVolume).toBe('function');
         media1.release();
     });
-	test("should return MediaError for bad filename", function() {
-		expect(2);
-		QUnit.stop(10000);
-		var badMedia = null;
-		var releaseMedia = function() {
-			badMedia.release();
-		};
-		var win = function() {
-			ok(0, "should NOT succeed with bad media file name");
-			releaseMedia();
-			QUnit.start();
-		};
-		var fail = function(result){
-			ok(typeof result == 'object', "Object returned in media.play failure callback is of type
'object' (actually MediaError).");
-			ok(result.code == MediaError.MEDIA_ERR_ABORTED, "Object returned in media.find failure
callback has a code property which equal to MediaError.MEDIA_ERR_ABORTED");
-			releaseMedia();
-			QUnit.start(); 
-		};
-		badMedia = new Media("invalid.file.name", win,fail);
-		badMedia.play();
+
+	it("should return MediaError for bad filename", function() {
+		var badMedia = null,
+            win = jasmine.createSpy(),
+            fail = jasmine.createSpy().andCallFake(function (result) {
+                expect(result).toBeDefined();
+                expect(result.code).toBe(MediaError.MEDIA_ERR_ABORTED);
+            });
+            
+        runs(function () {
+            badMedia = new Media("invalid.file.name", win,fail);
+            badMedia.play();
+        });
+
+        waitsFor(function () { return fail.wasCalled; }, Tests.TEST_TIMEOUT);
+
+        runs(function () {
+            expect(win).not.toHaveBeenCalled();
+            badMedia.release();
+        });
 	});
-    test("position should be set properly", function() {
-        var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
+
+    it("position should be set properly", function() {
+        var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"),
+            test = jasmine.createSpy().andCallFake(function(position) {
+                    console.log("position = " + position);
+                    expect(position).toBeGreaterThan(0.0);
+                    media1.stop()
+                    media1.release();
+                });
+
         media1.play();
-        expect(1);
-        QUnit.stop(15000);
-        setTimeout(
-                function() {
-                    media1.getCurrentPosition(
-                        function(position) {
-                            console.log("position = " + position);
-                            ok(position >= 0.0, "position should not be -1");
-                            QUnit.start();
-                            media1.stop()
-                            media1.release();
-                        },
-                        function(e) {
-                            QUnit.start();
-                        }
-                    );
-                }
-           , 5000);
+
+        waits(5000);
+
+        runs(function () {
+            media1.getCurrentPosition(test, function () {});
+        });
+
+        waitsFor(function () { return test.wasCalled; }, Tests.TEST_TIMEOUT);
     });
-    test("duration should be set properly", function() {
+
+    it("duration should be set properly", function() {
         var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
         media1.play();
-        expect(1);
-        QUnit.stop(15000);
-        setTimeout(
-                function() {
-                    ok(media1.getDuration() >= 0.0, "duration should not be -1");
-                    QUnit.start();
-                    media1.stop()
-                    media1.release();
-                }
-           , 5000);
+        waits(5000);
+        runs(function () {
+            expect(media1.getDuration()).toBeGreaterThan(0.0);
+        });
     });
-};
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d62a7909/tests/MobileSpecUnitTests/www/autotest/tests/network.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/network.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/network.tests.js
index af87d73..780097f 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/network.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/network.tests.js
@@ -1,26 +1,25 @@
-Tests.prototype.NetworkTests = function() {
-	module('Network (navigator.network)');
-	test("should exist", function() {
-  		expect(1);
-  		ok(navigator.network != null, "navigator.network should not be null.");
+describe('Network (navigator.network)', function () {
+	it("should exist", function() {
+        expect(navigator.network).toBeDefined();
 	});
-    module('Network Information API');
-    test("connection should exist", function() {
-        expect(1);
-        ok(navigator.network.connection != null, "navigator.network.connection should not
be null.");
+
+    describe('Network Information API', function () {
+        it("connection should exist", function() {
+            expect(navigator.network.connection).toBeDefined();
+        });
+
+        it("should contain connection properties", function() {
+            expect(navigator.network.connection.type).toBeDefined();
+        });
+
+        it("should define constants for connection status", function() {
+            expect(Connection.UNKNOWN).toBe("unknown");
+            expect(Connection.ETHERNET).toBe("ethernet");
+            expect(Connection.WIFI).toBe("wifi");
+            expect(Connection.CELL_2G).toBe("2g");
+            expect(Connection.CELL_3G).toBe("3g");
+            expect(Connection.CELL_4G).toBe("4g");
+            expect(Connection.NONE).toBe("none");
+        });
     });
-    test("should contain connection properties", function() {
-        expect(1);
-        ok(typeof navigator.network.connection.type != 'undefined', "navigator.network.connection.type
is defined.");
-    });
-    test("should define constants for connection status", function() {
-        expect(7);
-        equals(Connection.UNKNOWN, "unknown", "Connection.UNKNOWN is equal to 'unknown'.");
-        equals(Connection.ETHERNET, "ethernet", "Connection.ETHERNET is equal to 'ethernet'.");
-        equals(Connection.WIFI, "wifi", "Connection.WIFI is equal to 'wifi'.");
-        equals(Connection.CELL_2G, "2g", "Connection.CELL_2G is equal to '2g'.");
-        equals(Connection.CELL_3G, "3g", "Connection.CELL_3G is equal to '3g'.");
-        equals(Connection.CELL_4G, "4g", "Connection.CELL_4G is equal to '4g'.");
-        equals(Connection.NONE, "none", "Connection.NONE is equal to 'none'.");
-    });
-};
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d62a7909/tests/MobileSpecUnitTests/www/autotest/tests/notification.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/notification.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/notification.tests.js
index 03e3885..61c795d 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/notification.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/notification.tests.js
@@ -1,22 +1,20 @@
-Tests.prototype.NotificationTests = function() {	
-	module('Notification (navigator.notification)');
-	test("should exist", function() {
-  		expect(1);
-  		ok(navigator.notification != null, "navigator.notification should not be null.");
+describe('Notification (navigator.notification)', function () {
+	it("should exist", function() {
+        expect(navigator.notification).toBeDefined();
 	});
-	test("should contain a vibrate function", function() {
-		expect(2);
-		ok(typeof navigator.notification.vibrate != 'undefined' && navigator.notification.vibrate
!= null, "navigator.notification.vibrate should not be null.");
-		ok(typeof navigator.notification.vibrate == 'function', "navigator.notification.vibrate
should be a function.");
+
+	it("should contain a vibrate function", function() {
+		expect(typeof navigator.notification.vibrate).toBeDefined();
+		expect(typeof navigator.notification.vibrate).toBe("function");
 	});
-	test("should contain a beep function", function() {
-		expect(2);
-		ok(typeof navigator.notification.beep != 'undefined' && navigator.notification.beep
!= null, "navigator.notification.beep should not be null.");
-		ok(typeof navigator.notification.beep == 'function', "navigator.notification.beep should
be a function.");
+
+	it("should contain a beep function", function() {
+		expect(typeof navigator.notification.beep).toBeDefined();
+		expect(typeof navigator.notification.beep).toBe("function");
 	});
-	test("should contain a alert function", function() {
-		expect(2);
-		ok(typeof navigator.notification.alert != 'undefined' && navigator.notification.alert
!= null, "navigator.notification.alert should not be null.");
-		ok(typeof navigator.notification.alert == 'function', "navigator.notification.alert should
be a function.");
+
+	it("should contain a alert function", function() {
+		expect(typeof navigator.notification.alert).toBeDefined();
+		expect(typeof navigator.notification.alert).toBe("function");
 	});
-};
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d62a7909/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js
index 67fb28c..6b1a0ed 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/platform.tests.js
@@ -1,37 +1,35 @@
-Tests.prototype.PlatformTests = function() {	
-    module('Platform (cordova)');
-    test("should exist", function() {
-        expect(1);
-        ok(typeof cordova != 'undefined' && cordova != null, "cordova should not
be null.");
+describe('Platform (cordova)', function () {
+    it("should exist", function() {
+        expect(cordova).toBeDefined();
     });
-    module('Platform (Cordova)');
-    test("should not exist", function() {
-        expect(1);
-        ok(typeof Cordova == 'undefined', "Cordova should be null.");
+    describe('Platform (Cordova)', function () {
+        it("should not exist", function() {
+            expect(window.Cordova).not.toBeDefined();
+        });
     });
-    module('Platform (PhoneGap)');
-    test("should exist", function() {
-        expect(1);
-        ok(typeof PhoneGap != 'undefined' && PhoneGap != null, "PhoneGap should not
be null.");
+    describe('Platform (PhoneGap)', function () {
+        it("should exist", function() {
+            expect(PhoneGap).toBeDefined();
+        });
+
+        it("exec method should exist", function() {
+            expect(PhoneGap.exec).toBeDefined();
+            expect(typeof PhoneGap.exec).toBe('function');
+        });
+
+        it("addPlugin method should exist", function() {
+            expect(PhoneGap.addPlugin).toBeDefined();
+            expect(typeof PhoneGap.addPlugin).toBe('function');
+        });
+
+        it("addConstructor method should exist", function() {
+            expect(PhoneGap.addConstructor).toBeDefined();
+            expect(typeof PhoneGap.addConstructor).toBe('function');
+        });
     });
-    test("exec method should exist", function() {
-        expect(2);
-        ok(typeof PhoneGap.exec != 'undefined' && PhoneGap.exec != null, "PhoneGap.exec
should not be null.");
-        ok(typeof PhoneGap.exec == 'function', "PhoneGap.exec should be a function.");
+    describe('Platform (window.plugins)', function () {
+        it("should exist", function() {
+            expect(window.plugins).toBeDefined();
+        });
     });
-    test("addPlugin method should exist", function() {
-        expect(2);
-        ok(typeof PhoneGap.addPlugin != 'undefined' && PhoneGap.addPlugin != null,
"PhoneGap.addPlugin should not be null.");
-        ok(typeof PhoneGap.addPlugin == 'function', "PhoneGap.addPlugin should be a function.");
-    });
-    test("addConstructor method should exist", function() {
-        expect(2);
-        ok(typeof PhoneGap.addConstructor != 'undefined' && PhoneGap.addConstructor
!= null, "PhoneGap.addConstructor should not be null.");
-        ok(typeof PhoneGap.addConstructor == 'function', "PhoneGap.addConstructor should
be a function.");
-    });
-    module('Platform (window.plugins)');
-    test("should exist", function() {
-        expect(1);
-        ok(typeof window.plugins != 'undefined' && window.plugins != null, "window.plugins
should not be null.");
-    });
-};
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d62a7909/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
index 41476d8..a921de3 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
@@ -1,170 +1,161 @@
-Tests.prototype.StorageTests = function() 
-{
-  module("Session Storage");
-  test("should exist", function() {
-	expect(7);
-	ok(window.sessionStorage != null, "sessionStorage is defined");
-    ok(typeof window.sessionStorage.length != 'undefined', "sessionStorage.length is defined");
-    ok(typeof(window.sessionStorage.key) == "function", "sessionStorage.key is defined");
-    ok(typeof(window.sessionStorage.getItem) == "function", "sessionStorage.getItem is defined");
-    ok(typeof(window.sessionStorage.setItem) == "function", "sessionStorage.setItem is defined");
-    ok(typeof(window.sessionStorage.removeItem) == "function", "sessionStorage.removeItem
is defined");
-    ok(typeof(window.sessionStorage.clear) == "function", "sessionStorage.clear is defined");
-  });
-  test("check length", function() {
-    expect(3);
-    ok(window.sessionStorage.length == 0, "length should be 0");
-    window.sessionStorage.setItem("key","value");
-    ok(window.sessionStorage.length == 1, "length should be 1");
-    window.sessionStorage.removeItem("key");   
-    ok(window.sessionStorage.length == 0, "length should be 0");
-  });
-  test("check key", function() {
-	expect(3);
-	ok(window.sessionStorage.key(0) == null, "key should be null");
-	window.sessionStorage.setItem("test","value");
-	ok(window.sessionStorage.key(0) == "test", "key should be 'test'");
-	window.sessionStorage.removeItem("test");   
-	ok(window.sessionStorage.key(0) == null, "key should be null");
-  });
-  test("check getItem", function() {
-	expect(3);
-    ok(window.sessionStorage.getItem("item") == null, "item should be null");
-    window.sessionStorage.setItem("item","value");
-    ok(window.sessionStorage.getItem("item") == "value", "The value of the item should be
'value'");
-    window.sessionStorage.removeItem("item");   
-    ok(window.sessionStorage.getItem("item") == null, "item should be null");
-  });
-  test("check setItem", function() {
-    expect(4);
-    ok(window.sessionStorage.getItem("item") == null, "item should be null");
-    window.sessionStorage.setItem("item","value");
-    ok(window.sessionStorage.getItem("item") == "value", "The value of the item should be
'value'");
-    window.sessionStorage.setItem("item","newval");
-    ok(window.sessionStorage.getItem("item") == "newval", "The value of the item should be
'newval'");
-    window.sessionStorage.removeItem("item");   
-    ok(window.sessionStorage.getItem("item") == null, "item should be null");
-  });
-  test("check removeItem", function() {
-    expect(3);
-    ok(window.sessionStorage.getItem("item") == null, "item should be null");
-    window.sessionStorage.setItem("item","value");
-    ok(window.sessionStorage.getItem("item") == "value", "The value of the item should be
'value'");
-    window.sessionStorage.removeItem("item");   
-    ok(window.sessionStorage.getItem("item") == null, "item should be null");
-  });
-  test("check clear", function() {
-    expect(11);
-    ok(window.sessionStorage.getItem("item1") == null, "item1 should be null");
-    ok(window.sessionStorage.getItem("item2") == null, "item2 should be null");
-    ok(window.sessionStorage.getItem("item3") == null, "item3 should be null");
-    window.sessionStorage.setItem("item1","value");
-    window.sessionStorage.setItem("item2","value");
-    window.sessionStorage.setItem("item3","value");
-    ok(window.sessionStorage.getItem("item1") == "value", "item1 should be null");
-    ok(window.sessionStorage.getItem("item2") == "value", "item2 should be null");
-    ok(window.sessionStorage.getItem("item3") == "value", "item3 should be null");	    
-    ok(window.sessionStorage.length == 3, "length should be 3");
-    window.sessionStorage.clear();
-    ok(window.sessionStorage.length == 0, "length should be 0");
-    ok(window.sessionStorage.getItem("item1") == null, "item1 should be null");
-    ok(window.sessionStorage.getItem("item2") == null, "item2 should be null");
-    ok(window.sessionStorage.getItem("item3") == null, "item3 should be null");	    
-  });
-  test("check dot notation", function() {
-    expect(3);
-    ok(window.sessionStorage.item == null, "item should be null");
-    window.sessionStorage.item = "value";
-    ok(window.sessionStorage.item == "value", "The value of the item should be 'value'");
-    window.sessionStorage.removeItem("item");   
-    ok(window.sessionStorage.item == null, "item should be null");
-  });
-  module("Local Storage");
-  test("should exist", function() {
-	expect(7);
-	ok(window.localStorage != null, "localStorage is defined");
-    ok(typeof window.localStorage.length != 'undefined', "localStorage.length is defined");
-    ok(typeof(window.localStorage.key) == "function", "localStorage.key is defined");
-    ok(typeof(window.localStorage.getItem) == "function", "localStorage.getItem is defined");
-    ok(typeof(window.localStorage.setItem) == "function", "localStorage.setItem is defined");
-    ok(typeof(window.localStorage.removeItem) == "function", "localStorage.removeItem is
defined");
-    ok(typeof(window.localStorage.clear) == "function", "localStorage.clear is defined");
-  });  
-  test("check length", function() {
-    expect(3);
-    ok(window.localStorage.length == 0, "length should be 0");
-    window.localStorage.setItem("key","value");
-    ok(window.localStorage.length == 1, "length should be 1");
-    window.localStorage.removeItem("key");   
-    ok(window.localStorage.length == 0, "length should be 0");
-  });
-  test("check key", function() {
-    expect(3);
-    ok(window.localStorage.key(0) == null, "key should be null");
-    window.localStorage.setItem("test","value");
-    ok(window.localStorage.key(0) == "test", "key should be 'test'");
-    window.localStorage.removeItem("test");   
-    ok(window.localStorage.key(0) == null, "key should be null");
-  });
-  test("check getItem", function() {
-    expect(3);
-    ok(window.localStorage.getItem("item") == null, "item should be null");
-    window.localStorage.setItem("item","value");
-    ok(window.localStorage.getItem("item") == "value", "The value of the item should be 'value'");
-    window.localStorage.removeItem("item");   
-    ok(window.localStorage.getItem("item") == null, "item should be null");
-  });
-  test("check setItem", function() {
-    expect(4);
-    ok(window.localStorage.getItem("item") == null, "item should be null");
-    window.localStorage.setItem("item","value");
-    ok(window.localStorage.getItem("item") == "value", "The value of the item should be 'value'");
-    window.localStorage.setItem("item","newval");
-    ok(window.localStorage.getItem("item") == "newval", "The value of the item should be
'newval'");
-    window.localStorage.removeItem("item");   
-    ok(window.localStorage.getItem("item") == null, "item should be null");
-  });
-  test("check removeItem", function() {
-    expect(3);
-    ok(window.localStorage.getItem("item") == null, "item should be null");
-    window.localStorage.setItem("item","value");
-    ok(window.localStorage.getItem("item") == "value", "The value of the item should be 'value'");
-    window.localStorage.removeItem("item");   
-    ok(window.localStorage.getItem("item") == null, "item should be null");
-  });
-  test("check clear", function() {
-    expect(11);
-    ok(window.localStorage.getItem("item1") == null, "item1 should be null");
-    ok(window.localStorage.getItem("item2") == null, "item2 should be null");
-    ok(window.localStorage.getItem("item3") == null, "item3 should be null");
-    window.localStorage.setItem("item1","value");
-    window.localStorage.setItem("item2","value");
-    window.localStorage.setItem("item3","value");
-    ok(window.localStorage.getItem("item1") == "value", "item1 should be null");
-    ok(window.localStorage.getItem("item2") == "value", "item2 should be null");
-    ok(window.localStorage.getItem("item3") == "value", "item3 should be null");	    
-    ok(window.localStorage.length == 3, "length should be 3");
-    window.localStorage.clear();
-    ok(window.localStorage.length == 0, "length should be 0");
-    ok(window.localStorage.getItem("item1") == null, "item1 should be null");
-    ok(window.localStorage.getItem("item2") == null, "item2 should be null");
-    ok(window.localStorage.getItem("item3") == null, "item3 should be null");	    
-  });
-  test("check dot notation", function() {
-    expect(3);
-    ok(window.localStorage.item == null, "item should be null");
-    window.localStorage.item = "value";
-    ok(window.localStorage.item == "value", "The value of the item should be 'value'");
-    window.localStorage.removeItem("item");   
-    ok(window.localStorage.item == null, "item should be null");
-  });
-  module("HTML 5 Storage");
-  test("should exist", function() {
-    expect(1);
-    ok(typeof(window.openDatabase) == "function", "Database is defined");
-  });
-  test("Should open a database", function() {
-    var db = openDatabase("Database", "1.0", "HTML5 Database API example", 200000);
-    ok(db != null, "Database should be opened");
-  });
-}
+describe("Session Storage", function () {
+    it("should exist", function () {
+        expect(window.sessionStorage).toBeDefined();
+        expect(typeof window.sessionStorage.length).not.toBe('undefined');
+        expect(typeof(window.sessionStorage.key)).toBe('function');
+        expect(typeof(window.sessionStorage.getItem)).toBe('function');
+        expect(typeof(window.sessionStorage.setItem)).toBe('function');
+        expect(typeof(window.sessionStorage.removeItem)).toBe('function');
+        expect(typeof(window.sessionStorage.clear)).toBe('function');
+    });
+
+    it("check length", function () {
+        expect(window.sessionStorage.length).toBe(0);
+        window.sessionStorage.setItem("key","value");
+        expect(window.sessionStorage.length).toBe(1);
+        window.sessionStorage.removeItem("key");   
+        expect(window.sessionStorage.length).toBe(0);
+    });
+
+    it("check key", function () {
+        expect(window.sessionStorage.key(0)).toBe(null);
+        window.sessionStorage.setItem("test","value");
+        expect(window.sessionStorage.key(0)).toBe("test");
+        window.sessionStorage.removeItem("test");   
+        expect(window.sessionStorage.key(0)).toBe(null);
+    });
+
+    it("check getItem", function() {
+        expect(window.sessionStorage.getItem("item")).toBe(null);
+        window.sessionStorage.setItem("item","value");
+        expect(window.sessionStorage.getItem("item")).toBe("value");
+        window.sessionStorage.removeItem("item");   
+        expect(window.sessionStorage.getItem("item")).toBe(null);
+    });
+
+    it("check setItem", function() {
+        expect(window.sessionStorage.getItem("item")).toBe(null);
+        window.sessionStorage.setItem("item","value");
+        expect(window.sessionStorage.getItem("item")).toBe("value");
+        window.sessionStorage.setItem("item","newval");
+        expect(window.sessionStorage.getItem("item")).toBe("newval");
+        window.sessionStorage.removeItem("item");   
+        expect(window.sessionStorage.getItem("item")).toBe(null);
+    });
+
+    it("can remove an item", function () {
+        expect(window.sessionStorage.getItem("item")).toBe(null);
+        window.sessionStorage.setItem("item","value");
+        expect(window.sessionStorage.getItem("item")).toBe("value");
+        window.sessionStorage.removeItem("item");   
+        expect(window.sessionStorage.getItem("item")).toBe(null);
+    });
+
+    it("check clear", function() {
+        window.sessionStorage.setItem("item1","value");
+        window.sessionStorage.setItem("item2","value");
+        window.sessionStorage.setItem("item3","value");
+        expect(window.sessionStorage.length).toBe(3);
+        window.sessionStorage.clear();
+        expect(window.sessionStorage.length).toBe(0);
+    });
+
+    it("check dot notation", function() {
+        expect(window.sessionStorage.item).not.toBeDefined();
+        window.sessionStorage.item = "value";
+        expect(window.sessionStorage.item).toBe("value");
+        window.sessionStorage.removeItem("item");   
+        expect(window.sessionStorage.item).not.toBeDefined();
+    });
+
+    describe("Local Storage", function () {
+        it("should exist", function() {
+            expect(window.localStorage).toBeDefined();
+            expect(window.localStorage.length).toBeDefined();
+            expect(typeof window.localStorage.key).toBe("function");
+            expect(typeof window.localStorage.getItem).toBe("function");
+            expect(typeof window.localStorage.setItem).toBe("function");
+            expect(typeof window.localStorage.removeItem).toBe("function");
+            expect(typeof window.localStorage.clear).toBe("function");
+        });  
+
+        it("check length", function() {
+            expect(window.localStorage.length).toBe(0);
+            window.localStorage.setItem("key","value");
+            expect(window.localStorage.length).toBe(1);
+            window.localStorage.removeItem("key");   
+            expect(window.localStorage.length).toBe(0);
+        });
+
+        it("check key", function() {
+            expect(window.localStorage.key(0)).toBe(null);
+            window.localStorage.setItem("test","value");
+            expect(window.localStorage.key(0)).toBe("test");
+            window.localStorage.removeItem("test");   
+            expect(window.localStorage.key(0)).toBe(null);
+        });
+
+        it("check getItem", function() {
+            expect(window.localStorage.getItem("item")).toBe(null);
+            window.localStorage.setItem("item","value");
+            expect(window.localStorage.getItem("item")).toBe("value");
+            window.localStorage.removeItem("item");   
+            expect(window.localStorage.getItem("item")).toBe(null);
+        });
+
+        it("check setItem", function() {
+            expect(window.localStorage.getItem("item")).toBe(null);
+            window.localStorage.setItem("item","value");
+            expect(window.localStorage.getItem("item")).toBe("value");
+            window.localStorage.setItem("item","newval");
+            expect(window.localStorage.getItem("item")).toBe("newval");
+            window.localStorage.removeItem("item");   
+            expect(window.localStorage.getItem("item")).toBe(null);
+        });
+
+        it("check removeItem", function() {
+            expect(window.localStorage.getItem("item")).toBe(null);
+            window.localStorage.setItem("item","value");
+            expect(window.localStorage.getItem("item")).toBe("value");
+            window.localStorage.removeItem("item");   
+            expect(window.localStorage.getItem("item")).toBe(null);
+        });
+
+        it("check clear", function() {
+            expect(window.localStorage.getItem("item1")).toBe(null);
+            expect(window.localStorage.getItem("item2")).toBe(null);
+            expect(window.localStorage.getItem("item3")).toBe(null);
+            window.localStorage.setItem("item1","value");
+            window.localStorage.setItem("item2","value");
+            window.localStorage.setItem("item3","value");
+            expect(window.localStorage.getItem("item1")).toBe("value");
+            expect(window.localStorage.getItem("item2")).toBe("value");
+            expect(window.localStorage.getItem("item3")).toBe("value");
+            expect(window.localStorage.length).toBe(3);
+            window.localStorage.clear();
+            expect(window.localStorage.length).toBe(0);
+            expect(window.localStorage.getItem("item1")).toBe(null);
+            expect(window.localStorage.getItem("item2")).toBe(null);
+            expect(window.localStorage.getItem("item3")).toBe(null);
+        });
+
+        it("check dot notation", function() {
+            expect(window.localStorage.item).not.toBeDefined();
+            window.localStorage.item = "value";
+            expect(window.localStorage.item).toBe("value");
+            window.localStorage.removeItem("item");   
+            expect(window.localStorage.item).not.toBeDefined();
+        });
+    });
+
+    describe("HTML 5 Storage", function () {
+        it("should exist", function() {
+            expect(window.openDatabase);
+        });
+
+        it("Should open a database", function() {
+            var db = openDatabase("Database", "1.0", "HTML5 Database API example", 200000);
+            expect(db).toBeDefined();
+        });
+    });
+});


Mime
View raw message