Adding failure test case for Globalization.stringToDate()

Project: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/f5ffa48a
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/f5ffa48a
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/f5ffa48a

Branch: refs/heads/master
Commit: f5ffa48abf73564cb9b8d20dde4849ffeac52909
Parents: 80e69c2
Author: Simon MacDonald <simon.macdon...@gmail.com>
Authored: Thu Sep 27 11:19:27 2012 -0400
Committer: Simon MacDonald <simon.macdon...@gmail.com>
Committed: Thu Sep 27 11:19:27 2012 -0400

----------------------------------------------------------------------
 autotest/tests/globalization.tests.js |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/f5ffa48a/autotest/tests/globalization.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/globalization.tests.js 
b/autotest/tests/globalization.tests.js
index 76cbe9b..6903aee 100644
--- a/autotest/tests/globalization.tests.js
+++ b/autotest/tests/globalization.tests.js
@@ -284,6 +284,29 @@ describe('Globalization (navigator.globalization)', 
function () {
                 expect(fail).not.toHaveBeenCalled();
             });
         });
+        it("stringToDate using invalid date, error callback should be called 
with a GlobalizationError object", function() {
+            var win = jasmine.createSpy(),
+                fail = jasmine.createSpy().andCallFake(function(a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.code).toBeDefined();
+                    expect(typeof a.code).toBe('number');
+                    expect(a.code === 
GlobalizationError.PARSING_ERROR).toBe(true);
+                    expect(a.message).toBeDefined();
+                    expect(typeof a.message).toBe('string');
+                    expect(a.message !== "").toBe(true);
+                });
+
+            runs(function () {
+                navigator.globalization.stringToDate('notADate', win, fail, 
{selector:'foobar'});
+            });
+
+            waitsFor(function () { return fail.wasCalled; }, "fail never 
called", Tests.TEST_TIMEOUT);
+
+            runs(function () {
+                expect(win).not.toHaveBeenCalled();
+            });
+        });
     });
 
     describe("getDatePattern", function() {

Reply via email to