You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/08/07 22:26:22 UTC

[1/6] git commit: CB-6962 Ported globalization tests to framework

Repository: cordova-plugin-globalization
Updated Branches:
  refs/heads/master 7d27c45c2 -> 9136308d8


CB-6962 Ported globalization tests to framework

Tests will not be pulled into project with inclusion of plugin. Pending
changes to tooling to run with --test.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/9d9f5af7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/9d9f5af7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/9d9f5af7

Branch: refs/heads/master
Commit: 9d9f5af730c55137db7e63a08293cf4761b57ac8
Parents: 917019b
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Wed Jul 2 11:16:02 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Wed Jul 2 11:16:02 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 594 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 594 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/9d9f5af7/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
new file mode 100644
index 0000000..22fda7a
--- /dev/null
+++ b/test/tests.js
@@ -0,0 +1,594 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+exports.defineAutoTests = function () {
+    var fail = function (done) {
+        expect(true).toBe(false);
+        done();
+    };
+
+    describe('Globalization (navigator.globalization)', function () {
+
+        //not supported on bb10
+        if (cordova.platformId === 'blackberry10') {
+            return;
+        }
+
+        it("globalization.spec.1 should exist", function () {
+            expect(navigator.globalization).toBeDefined();
+        });
+
+        describe("getPreferredLanguage", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getPreferredLanguage).toBeDefined();
+                expect(typeof navigator.globalization.getPreferredLanguage == 'function').toBe(true);
+            });
+            it("globalization.spec.3 getPreferredLanguage success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getPreferredLanguage(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                },
+                fail.bind(null, done));
+            });
+        });
+
+        describe("getLocaleName", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getLocaleName).toBeDefined();
+                expect(typeof navigator.globalization.getLocaleName == 'function').toBe(true);
+            });
+            it("globalization.spec.3 getLocaleName success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getLocaleName(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done()
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe('Globalization Constants (window.Globalization)', function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(window.GlobalizationError).toBeDefined();
+                expect(window.GlobalizationError.UNKNOWN_ERROR).toBe(0);
+                expect(window.GlobalizationError.FORMATTING_ERROR).toBe(1);
+                expect(window.GlobalizationError.PARSING_ERROR).toBe(2);
+                expect(window.GlobalizationError.PATTERN_ERROR).toBe(3);
+            });
+        });
+
+        describe("dateToString", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.dateToString).toBeDefined();
+                expect(typeof navigator.globalization.dateToString == 'function').toBe(true);
+            });
+            it("globalization.spec.5 dateToString using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.6 dateToString using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'short', selector: 'date' });
+            });
+            it("globalization.spec.7 dateToString using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'full', selector: 'date' });
+            });
+            it("globalization.spec.8 dateToString using formatLength=medium and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'medium' });
+            });
+            it("globalization.spec.9 dateToString using formatLength=long and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'long' });
+            });
+            it("globalization.spec.10 dateToString using formatLength=full and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'full' });
+            });
+        });
+
+        describe("stringToDate", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.stringToDate).toBeDefined();
+                expect(typeof navigator.globalization.stringToDate == 'function').toBe(true);
+            });
+            it("globalization.spec.12 stringToDate using default options, success callback should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.year).toBeDefined();
+                    expect(typeof a.year).toBe('number');
+                    expect(a.year >= 0 && a.year <= 9999).toBe(true);
+                    expect(a.month).toBeDefined();
+                    expect(typeof a.month).toBe('number');
+                    expect(a.month >= 0 && a.month <= 11).toBe(true);
+                    expect(a.day).toBeDefined();
+                    expect(typeof a.day).toBe('number');
+                    expect(a.day >= 1 && a.day <= 31).toBe(true);
+                    expect(a.hour).toBeDefined();
+                    expect(typeof a.hour).toBe('number');
+                    expect(a.hour >= 0 && a.hour <= 23).toBe(true);
+                    expect(a.minute).toBeDefined();
+                    expect(typeof a.minute).toBe('number');
+                    expect(a.minute >= 0 && a.minute <= 59).toBe(true);
+                    expect(a.second).toBeDefined();
+                    expect(typeof a.second).toBe('number');
+                    expect(a.second >= 0 && a.second <= 59).toBe(true);
+                    expect(a.millisecond).toBeDefined();
+                    expect(typeof a.millisecond).toBe('number');
+                    done();
+                };
+
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done));
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.13 stringToDate using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.year).toBeDefined();
+                    expect(typeof a.year).toBe('number');
+                    expect(a.year >= 0 && a.year <= 9999).toBe(true);
+                    expect(a.month).toBeDefined();
+                    expect(typeof a.month).toBe('number');
+                    expect(a.month >= 0 && a.month <= 11).toBe(true);
+                    expect(a.day).toBeDefined();
+                    expect(typeof a.day).toBe('number');
+                    expect(a.day >= 1 && a.day <= 31).toBe(true);
+                    expect(a.hour).toBeDefined();
+                    expect(typeof a.hour).toBe('number');
+                    expect(a.hour >= 0 && a.hour <= 23).toBe(true);
+                    expect(a.minute).toBeDefined();
+                    expect(typeof a.minute).toBe('number');
+                    expect(a.minute >= 0 && a.minute <= 59).toBe(true);
+                    expect(a.second).toBeDefined();
+                    expect(typeof a.second).toBe('number');
+                    expect(a.second >= 0 && a.second <= 59).toBe(true);
+                    expect(a.millisecond).toBeDefined();
+                    expect(typeof a.millisecond).toBe('number');
+                    done();
+                };
+
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done), { formatLength: 'short', selector: 'date' });
+                }, fail.bind(null, done), { formatLength: 'short', selector: 'date' });
+            });
+            it("globalization.spec.14 stringToDate using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.year).toBeDefined();
+                    expect(typeof a.year).toBe('number');
+                    expect(a.year >= 0 && a.year <= 9999).toBe(true);
+                    expect(a.month).toBeDefined();
+                    expect(typeof a.month).toBe('number');
+                    expect(a.month >= 0 && a.month <= 11).toBe(true);
+                    expect(a.day).toBeDefined();
+                    expect(typeof a.day).toBe('number');
+                    expect(a.day >= 1 && a.day <= 31).toBe(true);
+                    expect(a.hour).toBeDefined();
+                    expect(typeof a.hour).toBe('number');
+                    expect(a.hour >= 0 && a.hour <= 23).toBe(true);
+                    expect(a.minute).toBeDefined();
+                    expect(typeof a.minute).toBe('number');
+                    expect(a.minute >= 0 && a.minute <= 59).toBe(true);
+                    expect(a.second).toBeDefined();
+                    expect(typeof a.second).toBe('number');
+                    expect(a.second >= 0 && a.second <= 59).toBe(true);
+                    expect(a.millisecond).toBeDefined();
+                    expect(typeof a.millisecond).toBe('number');
+                    done();
+                };
+
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done), { formatLength: 'full', selector: 'date' });
+                }, fail.bind(null, done), { formatLength: 'full', selector: 'date' });
+            });
+            it("globalization.spec.15 stringToDate using invalid date, error callback should be called with a GlobalizationError object", function (done) {
+                navigator.globalization.stringToDate('notADate', fail.bind(null, done), 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);
+                    done();
+                }, { selector: 'foobar' });
+            });
+        });
+
+        describe("getDatePattern", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getDatePattern).toBeDefined();
+                expect(typeof navigator.globalization.getDatePattern == 'function').toBe(true);
+            });
+            it("globalization.spec.17 getDatePattern using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDatePattern(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(a.timezone).toBeDefined();
+                    expect(typeof a.timezone).toBe('string');
+                    expect(a.timezone.length > 0).toBe(true);
+                    expect(a.utc_offset).toBeDefined();
+                    expect(typeof a.utc_offset).toBe('number');
+                    expect(a.dst_offset).toBeDefined();
+                    expect(typeof a.dst_offset).toBe('number');
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.18 getDatePattern using formatLength=medium and selector=date options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDatePattern(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(a.timezone).toBeDefined();
+                    expect(typeof a.timezone).toBe('string');
+                    expect(a.timezone.length > 0).toBe(true);
+                    expect(a.utc_offset).toBeDefined();
+                    expect(typeof a.utc_offset).toBe('number');
+                    expect(a.dst_offset).toBeDefined();
+                    expect(typeof a.dst_offset).toBe('number');
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'medium', selector: 'date' });
+            });
+        });
+
+        describe("getDateNames", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getDateNames).toBeDefined();
+                expect(typeof navigator.globalization.getDateNames == 'function').toBe(true);
+            });
+            it("globalization.spec.20 getDateNames using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(a.value instanceof Array).toBe(true);
+                    expect(a.value.length > 0).toBe(true);
+                    expect(typeof a.value[0]).toBe('string');
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.21 getDateNames using type=narrow and item=days options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(a.value instanceof Array).toBe(true);
+                    expect(a.value.length > 0).toBe(true);
+                    expect(typeof a.value[0]).toBe('string');
+                    done();
+                }, fail.bind(null, done),
+                { type: 'narrow', item: 'days' });
+            });
+            it("globalization.spec.22 getDateNames using type=narrow and item=months options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(a.value instanceof Array).toBe(true);
+                    expect(a.value.length > 0).toBe(true);
+                    expect(typeof a.value[0]).toBe('string');
+                    done();
+                }, fail.bind(null, done),
+                { type: 'narrow', item: 'months' });
+            });
+            it("globalization.spec.23 getDateNames using type=wide and item=days options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(a.value instanceof Array).toBe(true);
+                    expect(a.value.length > 0).toBe(true);
+                    expect(typeof a.value[0]).toBe('string');
+                    done();
+                }, fail.bind(null, done),
+                { type: 'wide', item: 'days' });
+            });
+            it("globalization.spec.24 getDateNames using type=wide and item=months options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(a.value instanceof Array).toBe(true);
+                    expect(a.value.length > 0).toBe(true);
+                    expect(typeof a.value[0]).toBe('string');
+                    done();
+                }, fail.bind(null, done),
+                { type: 'wide', item: 'months' });
+            });
+        });
+
+        describe("isDayLightSavingsTime", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.isDayLightSavingsTime).toBeDefined();
+                expect(typeof navigator.globalization.isDayLightSavingsTime == 'function').toBe(true);
+            });
+            it("globalization.spec.26 isDayLightSavingsTime using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.isDayLightSavingsTime(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.dst).toBeDefined();
+                    expect(typeof a.dst).toBe('boolean');
+                    done();
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe("getFirstDayOfWeek", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getFirstDayOfWeek).toBeDefined();
+                expect(typeof navigator.globalization.getFirstDayOfWeek == 'function').toBe(true);
+            });
+            it("globalization.spec.28 getFirstDayOfWeek success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getFirstDayOfWeek(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('number');
+                    done();
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe("numberToString", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.numberToString).toBeDefined();
+                expect(typeof navigator.globalization.numberToString == 'function').toBe(true);
+            });
+            it("globalization.spec.30 numberToString using default options, should be called with a Properties object", function (done) {
+                navigator.globalization.numberToString(3.25, function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.31 numberToString using type=percent options, should be called with a Properties object", function (done) {
+                navigator.globalization.numberToString(.25, function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'percent' });
+            });
+            it("globalization.spec.32 numberToString using type=currency options, should be called with a Properties object", function (done) {
+                navigator.globalization.numberToString(5.20, function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'currency' });
+            });
+        });
+
+        describe("stringToNumber", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.stringToNumber).toBeDefined();
+                expect(typeof navigator.globalization.stringToNumber == 'function').toBe(true);
+            });
+            it("globalization.spec.34 stringToNumber using default options, should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('number');
+                    expect(a.value > 0).toBe(true);
+                    done();
+                };
+
+                navigator.globalization.numberToString(3.25, function (a) {
+                    navigator.globalization.stringToNumber(a.value, win, fail.bind(null, done));
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.35 stringToNumber using type=percent options, should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('number');
+                    expect(a.value > 0).toBe(true);
+                    done();
+                };
+
+                navigator.globalization.numberToString(.25, function (a) {
+                    navigator.globalization.stringToNumber(a.value, win, fail.bind(null, done), { type: 'percent' });
+                }, fail.bind(null, done), { type: 'percent' });
+            });
+        });
+
+        describe("getNumberPattern", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getNumberPattern).toBeDefined();
+                expect(typeof navigator.globalization.getNumberPattern == 'function').toBe(true);
+            });
+            it("globalization.spec.37 getNumberPattern using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getNumberPattern(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(typeof a.symbol).toBe('string');
+                    expect(typeof a.fraction).toBe('number');
+                    expect(typeof a.rounding).toBe('number');
+                    expect(a.positive).toBeDefined();
+                    expect(typeof a.positive).toBe('string');
+                    expect(a.positive.length >= 0).toBe(true);
+                    expect(a.negative).toBeDefined();
+                    expect(typeof a.negative).toBe('string');
+                    expect(a.negative.length >= 0).toBe(true);
+                    expect(a.decimal).toBeDefined();
+                    expect(typeof a.decimal).toBe('string');
+                    expect(a.decimal.length > 0).toBe(true);
+                    expect(a.grouping).toBeDefined();
+                    expect(typeof a.grouping).toBe('string');
+                    expect(a.grouping.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.38 getNumberPattern using type=percent, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getNumberPattern(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(typeof a.symbol).toBe('string');
+                    expect(typeof a.fraction).toBe('number');
+                    expect(typeof a.rounding).toBe('number');
+                    expect(a.positive).toBeDefined();
+                    expect(typeof a.positive).toBe('string');
+                    expect(a.positive.length >= 0).toBe(true);
+                    expect(a.negative).toBeDefined();
+                    expect(typeof a.negative).toBe('string');
+                    expect(a.negative.length >= 0).toBe(true);
+                    expect(a.decimal).toBeDefined();
+                    expect(typeof a.decimal).toBe('string');
+                    expect(a.decimal.length > 0).toBe(true);
+                    expect(a.grouping).toBeDefined();
+                    expect(typeof a.grouping).toBe('string');
+                    expect(a.grouping.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done), { type: 'percent' });
+            });
+            it("globalization.spec.39 getNumberPattern using type=currency, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getNumberPattern(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(typeof a.symbol).toBe('string');
+                    expect(typeof a.fraction).toBe('number');
+                    expect(typeof a.rounding).toBe('number');
+                    expect(a.positive).toBeDefined();
+                    expect(typeof a.positive).toBe('string');
+                    expect(a.positive.length >= 0).toBe(true);
+                    expect(a.negative).toBeDefined();
+                    expect(typeof a.negative).toBe('string');
+                    expect(a.negative.length >= 0).toBe(true);
+                    expect(a.decimal).toBeDefined();
+                    expect(typeof a.decimal).toBe('string');
+                    expect(a.decimal.length > 0).toBe(true);
+                    expect(a.grouping).toBeDefined();
+                    expect(typeof a.grouping).toBe('string');
+                    expect(a.grouping.length > 0).toBe(true);
+                    done();
+                }, fail.bind(null, done), { type: 'currency' });
+            });
+        });
+
+        describe("getCurrencyPattern", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getCurrencyPattern).toBeDefined();
+                expect(typeof navigator.globalization.getCurrencyPattern == 'function').toBe(true);
+            });
+            it("globalization.spec.41 getCurrencyPattern using EUR for currency, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getCurrencyPattern("EUR", function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(a.code).toBeDefined();
+                    expect(typeof a.code).toBe('string');
+                    expect(a.code.length > 0).toBe(true);
+                    expect(typeof a.fraction).toBe('number');
+                    expect(typeof a.rounding).toBe('number');
+                    expect(a.decimal).toBeDefined();
+                    expect(typeof a.decimal).toBe('string');
+                    expect(a.decimal.length >= 0).toBe(true);
+                    expect(a.grouping).toBeDefined();
+                    expect(typeof a.grouping).toBe('string');
+                    expect(a.grouping.length >= 0).toBe(true);
+                    done();
+                }, fail.bind(null, done));
+            });
+        });
+    });
+};
+


[6/6] git commit: Merge branch 'cdvtest' of https://github.com/stacic/cordova-plugin-globalization

Posted by pu...@apache.org.
Merge branch 'cdvtest' of https://github.com/stacic/cordova-plugin-globalization


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/9136308d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/9136308d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/9136308d

Branch: refs/heads/master
Commit: 9136308d8ec1450d1cfc466898604e5a0b665e88
Parents: 7d27c45 8d40d5a
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Aug 7 13:25:36 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Aug 7 13:25:36 2014 -0700

----------------------------------------------------------------------
 tests/plugin.xml |  29 +++
 tests/tests.js   | 494 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 523 insertions(+)
----------------------------------------------------------------------



[5/6] git commit: Renamed test dir, added nested plugin.xml

Posted by pu...@apache.org.
Renamed test dir, added nested plugin.xml


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/8d40d5af
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/8d40d5af
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/8d40d5af

Branch: refs/heads/master
Commit: 8d40d5afafdcc73ec0c8cafa08ce280d59f0cd2b
Parents: 2d0e492
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Fri Aug 1 16:34:40 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Fri Aug 1 16:34:40 2014 -0400

----------------------------------------------------------------------
 test/tests.js    | 494 --------------------------------------------------
 tests/plugin.xml |  29 +++
 tests/tests.js   | 494 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 523 insertions(+), 494 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/8d40d5af/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
deleted file mode 100644
index 94f062d..0000000
--- a/test/tests.js
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*
-*/
-
-exports.defineAutoTests = function () {
-    var fail = function (done) {
-        expect(true).toBe(false);
-        done();
-    };
-
-    describe('Globalization (navigator.globalization)', function () {
-
-        //not supported on bb10
-        if (cordova.platformId === 'blackberry10') {
-            return;
-        }
-
-        it("globalization.spec.1 should exist", function () {
-            expect(navigator.globalization).toBeDefined();
-        });
-
-        describe("getPreferredLanguage", function () {
-            var checkPreferredLanguage = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.value).toBeDefined();
-                expect(typeof a.value).toBe('string');
-                expect(a.value.length > 0).toBe(true);
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getPreferredLanguage).toBeDefined();
-                expect(typeof navigator.globalization.getPreferredLanguage == 'function').toBe(true);
-            });
-            it("globalization.spec.3 getPreferredLanguage success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getPreferredLanguage(function (a) {
-                    checkPreferredLanguage(a);
-                    done();
-                },
-                fail.bind(null, done));
-            });
-            it("globalization.spec.4 getPreferredLanguage return string should have a hyphen", function (done) {
-                navigator.globalization.getPreferredLanguage(function (a) {
-                    checkPreferredLanguage(a);
-                    expect(a.value.indexOf('_')).toBe(-1);
-                    expect(a.value.indexOf('-')).toBeGreaterThan(0);
-                    done()
-                }, fail.bind(null, done));
-            });
-        });
-
-        describe("getLocaleName", function () {
-            var checkLocaleName = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.value).toBeDefined();
-                expect(typeof a.value).toBe('string');
-                expect(a.value.length > 0).toBe(true);
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getLocaleName).toBeDefined();
-                expect(typeof navigator.globalization.getLocaleName == 'function').toBe(true);
-            });
-            it("globalization.spec.3 getLocaleName success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getLocaleName(function (a) {
-                    checkLocaleName(a);
-                    done()
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.4 getLocaleName return string should have a hyphen", function (done) {
-                navigator.globalization.getLocaleName(function (a) {
-                    checkLocaleName(a);
-                    expect(a.value.indexOf('_')).toBe(-1);
-                    expect(a.value.indexOf('-')).toBeGreaterThan(0);
-                    done()
-                }, fail.bind(null, done));
-            });
-        });
-
-        describe('Globalization Constants (window.Globalization)', function () {
-            it("globalization.spec.1 should exist", function () {
-                expect(window.GlobalizationError).toBeDefined();
-                expect(window.GlobalizationError.UNKNOWN_ERROR).toBe(0);
-                expect(window.GlobalizationError.FORMATTING_ERROR).toBe(1);
-                expect(window.GlobalizationError.PARSING_ERROR).toBe(2);
-                expect(window.GlobalizationError.PATTERN_ERROR).toBe(3);
-            });
-        });
-
-        describe("dateToString", function () {
-            var checkDateToString = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.value).toBeDefined();
-                expect(typeof a.value).toBe('string');
-                expect(a.value.length > 0).toBe(true);
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.dateToString).toBeDefined();
-                expect(typeof navigator.globalization.dateToString == 'function').toBe(true);
-            });
-            it("globalization.spec.5 dateToString using default options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    checkDateToString(a);
-                    done();
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.6 dateToString using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    checkDateToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { formatLength: 'short', selector: 'date' });
-            });
-            it("globalization.spec.7 dateToString using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    checkDateToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { formatLength: 'full', selector: 'date' });
-            });
-            it("globalization.spec.8 dateToString using formatLength=medium and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    checkDateToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { formatLength: 'medium' });
-            });
-            it("globalization.spec.9 dateToString using formatLength=long and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    checkDateToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { formatLength: 'long' });
-            });
-            it("globalization.spec.10 dateToString using formatLength=full and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    checkDateToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { formatLength: 'full' });
-            });
-        });
-
-        describe("stringToDate", function () {
-            var checkStringToDate = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.year).toBeDefined();
-                expect(typeof a.year).toBe('number');
-                expect(a.year >= 0 && a.year <= 9999).toBe(true);
-                expect(a.month).toBeDefined();
-                expect(typeof a.month).toBe('number');
-                expect(a.month >= 0 && a.month <= 11).toBe(true);
-                expect(a.day).toBeDefined();
-                expect(typeof a.day).toBe('number');
-                expect(a.day >= 1 && a.day <= 31).toBe(true);
-                expect(a.hour).toBeDefined();
-                expect(typeof a.hour).toBe('number');
-                expect(a.hour >= 0 && a.hour <= 23).toBe(true);
-                expect(a.minute).toBeDefined();
-                expect(typeof a.minute).toBe('number');
-                expect(a.minute >= 0 && a.minute <= 59).toBe(true);
-                expect(a.second).toBeDefined();
-                expect(typeof a.second).toBe('number');
-                expect(a.second >= 0 && a.second <= 59).toBe(true);
-                expect(a.millisecond).toBeDefined();
-                expect(typeof a.millisecond).toBe('number');
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.stringToDate).toBeDefined();
-                expect(typeof navigator.globalization.stringToDate == 'function').toBe(true);
-            });
-            it("globalization.spec.12 stringToDate using default options, success callback should be called with a Properties object", function (done) {
-                var win = function (a) {
-                    checkStringToDate(a);
-                    done();
-                };
-
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done));
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.13 stringToDate using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
-                var win = function (a) {
-                    checkStringToDate(a);
-                    done();
-                };
-
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done), { formatLength: 'short', selector: 'date' });
-                }, fail.bind(null, done), { formatLength: 'short', selector: 'date' });
-            });
-            it("globalization.spec.14 stringToDate using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
-                var win = function (a) {
-                    checkStringToDate(a);
-                    done();
-                };
-
-                navigator.globalization.dateToString(new Date(), function (a) {
-                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done), { formatLength: 'full', selector: 'date' });
-                }, fail.bind(null, done), { formatLength: 'full', selector: 'date' });
-            });
-            it("globalization.spec.15 stringToDate using invalid date, error callback should be called with a GlobalizationError object", function (done) {
-                navigator.globalization.stringToDate('notADate', fail.bind(null, done), 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);
-                    done();
-                }, { selector: 'foobar' });
-            });
-        });
-
-        describe("getDatePattern", function () {
-            var checkDatePattern = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.pattern).toBeDefined();
-                expect(typeof a.pattern).toBe('string');
-                expect(a.pattern.length > 0).toBe(true);
-                expect(a.timezone).toBeDefined();
-                expect(typeof a.timezone).toBe('string');
-                expect(a.timezone.length > 0).toBe(true);
-                expect(a.utc_offset).toBeDefined();
-                expect(typeof a.utc_offset).toBe('number');
-                expect(a.dst_offset).toBeDefined();
-                expect(typeof a.dst_offset).toBe('number');
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getDatePattern).toBeDefined();
-                expect(typeof navigator.globalization.getDatePattern == 'function').toBe(true);
-            });
-            it("globalization.spec.17 getDatePattern using default options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDatePattern(function (a) {
-                    checkDatePattern(a);
-                    done();
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.18 getDatePattern using formatLength=medium and selector=date options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDatePattern(function (a) {
-                    checkDatePattern(a);
-                    done();
-                }, fail.bind(null, done),
-                { formatLength: 'medium', selector: 'date' });
-            });
-        });
-
-        describe("getDateNames", function () {
-            var checkDateNames = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.value).toBeDefined();
-                expect(a.value instanceof Array).toBe(true);
-                expect(a.value.length > 0).toBe(true);
-                expect(typeof a.value[0]).toBe('string');
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getDateNames).toBeDefined();
-                expect(typeof navigator.globalization.getDateNames == 'function').toBe(true);
-            });
-            it("globalization.spec.20 getDateNames using default options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDateNames(function (a) {
-                    checkDateNames(a);
-                    done();
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.21 getDateNames using type=narrow and item=days options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDateNames(function (a) {
-                    checkDateNames(a);
-                    done();
-                }, fail.bind(null, done),
-                { type: 'narrow', item: 'days' });
-            });
-            it("globalization.spec.22 getDateNames using type=narrow and item=months options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDateNames(function (a) {
-                    checkDateNames(a);
-                    done();
-                }, fail.bind(null, done),
-                { type: 'narrow', item: 'months' });
-            });
-            it("globalization.spec.23 getDateNames using type=wide and item=days options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDateNames(function (a) {
-                    checkDateNames(a);
-                    done();
-                }, fail.bind(null, done),
-                { type: 'wide', item: 'days' });
-            });
-            it("globalization.spec.24 getDateNames using type=wide and item=months options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getDateNames(function (a) {
-                    checkDateNames(a);
-                    done();
-                }, fail.bind(null, done),
-                { type: 'wide', item: 'months' });
-            });
-        });
-
-        describe("isDayLightSavingsTime", function () {
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.isDayLightSavingsTime).toBeDefined();
-                expect(typeof navigator.globalization.isDayLightSavingsTime == 'function').toBe(true);
-            });
-            it("globalization.spec.26 isDayLightSavingsTime using default options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.isDayLightSavingsTime(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.dst).toBeDefined();
-                    expect(typeof a.dst).toBe('boolean');
-                    done();
-                }, fail.bind(null, done));
-            });
-        });
-
-        describe("getFirstDayOfWeek", function () {
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getFirstDayOfWeek).toBeDefined();
-                expect(typeof navigator.globalization.getFirstDayOfWeek == 'function').toBe(true);
-            });
-            it("globalization.spec.28 getFirstDayOfWeek success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getFirstDayOfWeek(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('number');
-                    done();
-                }, fail.bind(null, done));
-            });
-        });
-
-        describe("numberToString", function () {
-            var checkNumberToString = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.value).toBeDefined();
-                expect(typeof a.value).toBe('string');
-                expect(a.value.length > 0).toBe(true);
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.numberToString).toBeDefined();
-                expect(typeof navigator.globalization.numberToString == 'function').toBe(true);
-            });
-            it("globalization.spec.30 numberToString using default options, should be called with a Properties object", function (done) {
-                navigator.globalization.numberToString(3.25, function (a) {
-                    checkNumberToString(a);
-                    done();
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.31 numberToString using type=percent options, should be called with a Properties object", function (done) {
-                navigator.globalization.numberToString(.25, function (a) {
-                    checkNumberToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { type: 'percent' });
-            });
-            it("globalization.spec.32 numberToString using type=currency options, should be called with a Properties object", function (done) {
-                navigator.globalization.numberToString(5.20, function (a) {
-                    checkNumberToString(a);
-                    done();
-                }, fail.bind(null, done),
-                { type: 'currency' });
-            });
-        });
-
-        describe("stringToNumber", function () {
-            var checkStringToNumber = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.value).toBeDefined();
-                expect(typeof a.value).toBe('number');
-                expect(a.value > 0).toBe(true);
-            };
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.stringToNumber).toBeDefined();
-                expect(typeof navigator.globalization.stringToNumber == 'function').toBe(true);
-            });
-            it("globalization.spec.34 stringToNumber using default options, should be called with a Properties object", function (done) {
-                var win = function (a) {
-                    checkStringToNumber(a);
-                    done();
-                };
-
-                navigator.globalization.numberToString(3.25, function (a) {
-                    navigator.globalization.stringToNumber(a.value, win, fail.bind(null, done));
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.35 stringToNumber using type=percent options, should be called with a Properties object", function (done) {
-                var win = function (a) {
-                    checkStringToNumber(a);
-                    done();
-                };
-
-                navigator.globalization.numberToString(.25, function (a) {
-                    navigator.globalization.stringToNumber(a.value, win, fail.bind(null, done), { type: 'percent' });
-                }, fail.bind(null, done), { type: 'percent' });
-            });
-        });
-
-        describe("getNumberPattern", function () {
-            var checkNumberPattern = function (a) {
-                expect(a).toBeDefined();
-                expect(typeof a).toBe('object');
-                expect(a.pattern).toBeDefined();
-                expect(typeof a.pattern).toBe('string');
-                expect(a.pattern.length > 0).toBe(true);
-                expect(typeof a.symbol).toBe('string');
-                expect(typeof a.fraction).toBe('number');
-                expect(typeof a.rounding).toBe('number');
-                expect(a.positive).toBeDefined();
-                expect(typeof a.positive).toBe('string');
-                expect(a.positive.length >= 0).toBe(true);
-                expect(a.negative).toBeDefined();
-                expect(typeof a.negative).toBe('string');
-                expect(a.negative.length >= 0).toBe(true);
-                expect(a.decimal).toBeDefined();
-                expect(typeof a.decimal).toBe('string');
-                expect(a.decimal.length > 0).toBe(true);
-                expect(a.grouping).toBeDefined();
-                expect(typeof a.grouping).toBe('string');
-                expect(a.grouping.length > 0).toBe(true);
-            };
-
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getNumberPattern).toBeDefined();
-                expect(typeof navigator.globalization.getNumberPattern == 'function').toBe(true);
-            });
-            it("globalization.spec.37 getNumberPattern using default options, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getNumberPattern(function (a) {
-                    checkNumberPattern(a);
-                    done();
-                }, fail.bind(null, done));
-            });
-            it("globalization.spec.38 getNumberPattern using type=percent, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getNumberPattern(function (a) {
-                    checkNumberPattern(a);
-                    done();
-                }, fail.bind(null, done), { type: 'percent' });
-            });
-            it("globalization.spec.39 getNumberPattern using type=currency, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getNumberPattern(function (a) {
-                    checkNumberPattern(a);
-                    done();
-                }, fail.bind(null, done), { type: 'currency' });
-            });
-        });
-
-        describe("getCurrencyPattern", function () {
-            it("globalization.spec.1 should exist", function () {
-                expect(typeof navigator.globalization.getCurrencyPattern).toBeDefined();
-                expect(typeof navigator.globalization.getCurrencyPattern == 'function').toBe(true);
-            });
-            it("globalization.spec.41 getCurrencyPattern using EUR for currency, success callback should be called with a Properties object", function (done) {
-                navigator.globalization.getCurrencyPattern("EUR", function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.pattern).toBeDefined();
-                    expect(typeof a.pattern).toBe('string');
-                    expect(a.pattern.length > 0).toBe(true);
-                    expect(a.code).toBeDefined();
-                    expect(typeof a.code).toBe('string');
-                    expect(a.code.length > 0).toBe(true);
-                    expect(typeof a.fraction).toBe('number');
-                    expect(typeof a.rounding).toBe('number');
-                    expect(a.decimal).toBeDefined();
-                    expect(typeof a.decimal).toBe('string');
-                    expect(a.decimal.length >= 0).toBe(true);
-                    expect(a.grouping).toBeDefined();
-                    expect(typeof a.grouping).toBe('string');
-                    expect(a.grouping.length >= 0).toBe(true);
-                    done();
-                }, fail.bind(null, done));
-            });
-        });
-    });
-};

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/8d40d5af/tests/plugin.xml
----------------------------------------------------------------------
diff --git a/tests/plugin.xml b/tests/plugin.xml
new file mode 100644
index 0000000..3fd30a3
--- /dev/null
+++ b/tests/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+    id="org.apache.cordova.globalization.tests"
+    version="0.2.9-dev">
+    <name>Cordova Globalization Plugin Tests</name>
+    <license>Apache 2.0</license>
+
+    <js-module src="tests.js" name="tests">
+    </js-module>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/8d40d5af/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
new file mode 100644
index 0000000..94f062d
--- /dev/null
+++ b/tests/tests.js
@@ -0,0 +1,494 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+exports.defineAutoTests = function () {
+    var fail = function (done) {
+        expect(true).toBe(false);
+        done();
+    };
+
+    describe('Globalization (navigator.globalization)', function () {
+
+        //not supported on bb10
+        if (cordova.platformId === 'blackberry10') {
+            return;
+        }
+
+        it("globalization.spec.1 should exist", function () {
+            expect(navigator.globalization).toBeDefined();
+        });
+
+        describe("getPreferredLanguage", function () {
+            var checkPreferredLanguage = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getPreferredLanguage).toBeDefined();
+                expect(typeof navigator.globalization.getPreferredLanguage == 'function').toBe(true);
+            });
+            it("globalization.spec.3 getPreferredLanguage success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getPreferredLanguage(function (a) {
+                    checkPreferredLanguage(a);
+                    done();
+                },
+                fail.bind(null, done));
+            });
+            it("globalization.spec.4 getPreferredLanguage return string should have a hyphen", function (done) {
+                navigator.globalization.getPreferredLanguage(function (a) {
+                    checkPreferredLanguage(a);
+                    expect(a.value.indexOf('_')).toBe(-1);
+                    expect(a.value.indexOf('-')).toBeGreaterThan(0);
+                    done()
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe("getLocaleName", function () {
+            var checkLocaleName = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getLocaleName).toBeDefined();
+                expect(typeof navigator.globalization.getLocaleName == 'function').toBe(true);
+            });
+            it("globalization.spec.3 getLocaleName success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getLocaleName(function (a) {
+                    checkLocaleName(a);
+                    done()
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.4 getLocaleName return string should have a hyphen", function (done) {
+                navigator.globalization.getLocaleName(function (a) {
+                    checkLocaleName(a);
+                    expect(a.value.indexOf('_')).toBe(-1);
+                    expect(a.value.indexOf('-')).toBeGreaterThan(0);
+                    done()
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe('Globalization Constants (window.Globalization)', function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(window.GlobalizationError).toBeDefined();
+                expect(window.GlobalizationError.UNKNOWN_ERROR).toBe(0);
+                expect(window.GlobalizationError.FORMATTING_ERROR).toBe(1);
+                expect(window.GlobalizationError.PARSING_ERROR).toBe(2);
+                expect(window.GlobalizationError.PATTERN_ERROR).toBe(3);
+            });
+        });
+
+        describe("dateToString", function () {
+            var checkDateToString = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.dateToString).toBeDefined();
+                expect(typeof navigator.globalization.dateToString == 'function').toBe(true);
+            });
+            it("globalization.spec.5 dateToString using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    checkDateToString(a);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.6 dateToString using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    checkDateToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'short', selector: 'date' });
+            });
+            it("globalization.spec.7 dateToString using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    checkDateToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'full', selector: 'date' });
+            });
+            it("globalization.spec.8 dateToString using formatLength=medium and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    checkDateToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'medium' });
+            });
+            it("globalization.spec.9 dateToString using formatLength=long and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    checkDateToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'long' });
+            });
+            it("globalization.spec.10 dateToString using formatLength=full and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    checkDateToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'full' });
+            });
+        });
+
+        describe("stringToDate", function () {
+            var checkStringToDate = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.year).toBeDefined();
+                expect(typeof a.year).toBe('number');
+                expect(a.year >= 0 && a.year <= 9999).toBe(true);
+                expect(a.month).toBeDefined();
+                expect(typeof a.month).toBe('number');
+                expect(a.month >= 0 && a.month <= 11).toBe(true);
+                expect(a.day).toBeDefined();
+                expect(typeof a.day).toBe('number');
+                expect(a.day >= 1 && a.day <= 31).toBe(true);
+                expect(a.hour).toBeDefined();
+                expect(typeof a.hour).toBe('number');
+                expect(a.hour >= 0 && a.hour <= 23).toBe(true);
+                expect(a.minute).toBeDefined();
+                expect(typeof a.minute).toBe('number');
+                expect(a.minute >= 0 && a.minute <= 59).toBe(true);
+                expect(a.second).toBeDefined();
+                expect(typeof a.second).toBe('number');
+                expect(a.second >= 0 && a.second <= 59).toBe(true);
+                expect(a.millisecond).toBeDefined();
+                expect(typeof a.millisecond).toBe('number');
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.stringToDate).toBeDefined();
+                expect(typeof navigator.globalization.stringToDate == 'function').toBe(true);
+            });
+            it("globalization.spec.12 stringToDate using default options, success callback should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    checkStringToDate(a);
+                    done();
+                };
+
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done));
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.13 stringToDate using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    checkStringToDate(a);
+                    done();
+                };
+
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done), { formatLength: 'short', selector: 'date' });
+                }, fail.bind(null, done), { formatLength: 'short', selector: 'date' });
+            });
+            it("globalization.spec.14 stringToDate using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    checkStringToDate(a);
+                    done();
+                };
+
+                navigator.globalization.dateToString(new Date(), function (a) {
+                    navigator.globalization.stringToDate(a.value, win, fail.bind(null, done), { formatLength: 'full', selector: 'date' });
+                }, fail.bind(null, done), { formatLength: 'full', selector: 'date' });
+            });
+            it("globalization.spec.15 stringToDate using invalid date, error callback should be called with a GlobalizationError object", function (done) {
+                navigator.globalization.stringToDate('notADate', fail.bind(null, done), 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);
+                    done();
+                }, { selector: 'foobar' });
+            });
+        });
+
+        describe("getDatePattern", function () {
+            var checkDatePattern = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.pattern).toBeDefined();
+                expect(typeof a.pattern).toBe('string');
+                expect(a.pattern.length > 0).toBe(true);
+                expect(a.timezone).toBeDefined();
+                expect(typeof a.timezone).toBe('string');
+                expect(a.timezone.length > 0).toBe(true);
+                expect(a.utc_offset).toBeDefined();
+                expect(typeof a.utc_offset).toBe('number');
+                expect(a.dst_offset).toBeDefined();
+                expect(typeof a.dst_offset).toBe('number');
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getDatePattern).toBeDefined();
+                expect(typeof navigator.globalization.getDatePattern == 'function').toBe(true);
+            });
+            it("globalization.spec.17 getDatePattern using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDatePattern(function (a) {
+                    checkDatePattern(a);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.18 getDatePattern using formatLength=medium and selector=date options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDatePattern(function (a) {
+                    checkDatePattern(a);
+                    done();
+                }, fail.bind(null, done),
+                { formatLength: 'medium', selector: 'date' });
+            });
+        });
+
+        describe("getDateNames", function () {
+            var checkDateNames = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(a.value instanceof Array).toBe(true);
+                expect(a.value.length > 0).toBe(true);
+                expect(typeof a.value[0]).toBe('string');
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getDateNames).toBeDefined();
+                expect(typeof navigator.globalization.getDateNames == 'function').toBe(true);
+            });
+            it("globalization.spec.20 getDateNames using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    checkDateNames(a);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.21 getDateNames using type=narrow and item=days options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    checkDateNames(a);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'narrow', item: 'days' });
+            });
+            it("globalization.spec.22 getDateNames using type=narrow and item=months options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    checkDateNames(a);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'narrow', item: 'months' });
+            });
+            it("globalization.spec.23 getDateNames using type=wide and item=days options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    checkDateNames(a);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'wide', item: 'days' });
+            });
+            it("globalization.spec.24 getDateNames using type=wide and item=months options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getDateNames(function (a) {
+                    checkDateNames(a);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'wide', item: 'months' });
+            });
+        });
+
+        describe("isDayLightSavingsTime", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.isDayLightSavingsTime).toBeDefined();
+                expect(typeof navigator.globalization.isDayLightSavingsTime == 'function').toBe(true);
+            });
+            it("globalization.spec.26 isDayLightSavingsTime using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.isDayLightSavingsTime(new Date(), function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.dst).toBeDefined();
+                    expect(typeof a.dst).toBe('boolean');
+                    done();
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe("getFirstDayOfWeek", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getFirstDayOfWeek).toBeDefined();
+                expect(typeof navigator.globalization.getFirstDayOfWeek == 'function').toBe(true);
+            });
+            it("globalization.spec.28 getFirstDayOfWeek success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getFirstDayOfWeek(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('number');
+                    done();
+                }, fail.bind(null, done));
+            });
+        });
+
+        describe("numberToString", function () {
+            var checkNumberToString = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.numberToString).toBeDefined();
+                expect(typeof navigator.globalization.numberToString == 'function').toBe(true);
+            });
+            it("globalization.spec.30 numberToString using default options, should be called with a Properties object", function (done) {
+                navigator.globalization.numberToString(3.25, function (a) {
+                    checkNumberToString(a);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.31 numberToString using type=percent options, should be called with a Properties object", function (done) {
+                navigator.globalization.numberToString(.25, function (a) {
+                    checkNumberToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'percent' });
+            });
+            it("globalization.spec.32 numberToString using type=currency options, should be called with a Properties object", function (done) {
+                navigator.globalization.numberToString(5.20, function (a) {
+                    checkNumberToString(a);
+                    done();
+                }, fail.bind(null, done),
+                { type: 'currency' });
+            });
+        });
+
+        describe("stringToNumber", function () {
+            var checkStringToNumber = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('number');
+                expect(a.value > 0).toBe(true);
+            };
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.stringToNumber).toBeDefined();
+                expect(typeof navigator.globalization.stringToNumber == 'function').toBe(true);
+            });
+            it("globalization.spec.34 stringToNumber using default options, should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    checkStringToNumber(a);
+                    done();
+                };
+
+                navigator.globalization.numberToString(3.25, function (a) {
+                    navigator.globalization.stringToNumber(a.value, win, fail.bind(null, done));
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.35 stringToNumber using type=percent options, should be called with a Properties object", function (done) {
+                var win = function (a) {
+                    checkStringToNumber(a);
+                    done();
+                };
+
+                navigator.globalization.numberToString(.25, function (a) {
+                    navigator.globalization.stringToNumber(a.value, win, fail.bind(null, done), { type: 'percent' });
+                }, fail.bind(null, done), { type: 'percent' });
+            });
+        });
+
+        describe("getNumberPattern", function () {
+            var checkNumberPattern = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.pattern).toBeDefined();
+                expect(typeof a.pattern).toBe('string');
+                expect(a.pattern.length > 0).toBe(true);
+                expect(typeof a.symbol).toBe('string');
+                expect(typeof a.fraction).toBe('number');
+                expect(typeof a.rounding).toBe('number');
+                expect(a.positive).toBeDefined();
+                expect(typeof a.positive).toBe('string');
+                expect(a.positive.length >= 0).toBe(true);
+                expect(a.negative).toBeDefined();
+                expect(typeof a.negative).toBe('string');
+                expect(a.negative.length >= 0).toBe(true);
+                expect(a.decimal).toBeDefined();
+                expect(typeof a.decimal).toBe('string');
+                expect(a.decimal.length > 0).toBe(true);
+                expect(a.grouping).toBeDefined();
+                expect(typeof a.grouping).toBe('string');
+                expect(a.grouping.length > 0).toBe(true);
+            };
+
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getNumberPattern).toBeDefined();
+                expect(typeof navigator.globalization.getNumberPattern == 'function').toBe(true);
+            });
+            it("globalization.spec.37 getNumberPattern using default options, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getNumberPattern(function (a) {
+                    checkNumberPattern(a);
+                    done();
+                }, fail.bind(null, done));
+            });
+            it("globalization.spec.38 getNumberPattern using type=percent, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getNumberPattern(function (a) {
+                    checkNumberPattern(a);
+                    done();
+                }, fail.bind(null, done), { type: 'percent' });
+            });
+            it("globalization.spec.39 getNumberPattern using type=currency, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getNumberPattern(function (a) {
+                    checkNumberPattern(a);
+                    done();
+                }, fail.bind(null, done), { type: 'currency' });
+            });
+        });
+
+        describe("getCurrencyPattern", function () {
+            it("globalization.spec.1 should exist", function () {
+                expect(typeof navigator.globalization.getCurrencyPattern).toBeDefined();
+                expect(typeof navigator.globalization.getCurrencyPattern == 'function').toBe(true);
+            });
+            it("globalization.spec.41 getCurrencyPattern using EUR for currency, success callback should be called with a Properties object", function (done) {
+                navigator.globalization.getCurrencyPattern("EUR", function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.pattern).toBeDefined();
+                    expect(typeof a.pattern).toBe('string');
+                    expect(a.pattern.length > 0).toBe(true);
+                    expect(a.code).toBeDefined();
+                    expect(typeof a.code).toBe('string');
+                    expect(a.code.length > 0).toBe(true);
+                    expect(typeof a.fraction).toBe('number');
+                    expect(typeof a.rounding).toBe('number');
+                    expect(a.decimal).toBeDefined();
+                    expect(typeof a.decimal).toBe('string');
+                    expect(a.decimal.length >= 0).toBe(true);
+                    expect(a.grouping).toBeDefined();
+                    expect(typeof a.grouping).toBe('string');
+                    expect(a.grouping.length >= 0).toBe(true);
+                    done();
+                }, fail.bind(null, done));
+            });
+        });
+    });
+};


[4/6] git commit: Clean-up: removed duplicate code

Posted by pu...@apache.org.
Clean-up: removed duplicate code


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/2d0e4922
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/2d0e4922
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/2d0e4922

Branch: refs/heads/master
Commit: 2d0e49220a37fbf801e3462232c4a0ae86c5e63b
Parents: f5d7c8e
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Tue Jul 29 14:58:41 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Tue Jul 29 14:58:41 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 393 ++++++++++++++++++-----------------------------------
 1 file changed, 135 insertions(+), 258 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/2d0e4922/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 3b2df25..94f062d 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -37,28 +37,27 @@ exports.defineAutoTests = function () {
         });
 
         describe("getPreferredLanguage", function () {
+            var checkPreferredLanguage = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.getPreferredLanguage).toBeDefined();
                 expect(typeof navigator.globalization.getPreferredLanguage == 'function').toBe(true);
             });
             it("globalization.spec.3 getPreferredLanguage success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getPreferredLanguage(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkPreferredLanguage(a);
                     done();
                 },
                 fail.bind(null, done));
             });
-            it("globalization.spec.4 getPreferredLanguage return string should have hypen", function (done) {
+            it("globalization.spec.4 getPreferredLanguage return string should have a hyphen", function (done) {
                 navigator.globalization.getPreferredLanguage(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkPreferredLanguage(a);
                     expect(a.value.indexOf('_')).toBe(-1);
                     expect(a.value.indexOf('-')).toBeGreaterThan(0);
                     done()
@@ -67,27 +66,26 @@ exports.defineAutoTests = function () {
         });
 
         describe("getLocaleName", function () {
+            var checkLocaleName = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.getLocaleName).toBeDefined();
                 expect(typeof navigator.globalization.getLocaleName == 'function').toBe(true);
             });
             it("globalization.spec.3 getLocaleName success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getLocaleName(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkLocaleName(a);
                     done()
                 }, fail.bind(null, done));
             });
-             it("globalization.spec.4 getLocaleName return string should have hypen", function (done) {
+            it("globalization.spec.4 getLocaleName return string should have a hyphen", function (done) {
                 navigator.globalization.getLocaleName(function (a) {
-                   expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkLocaleName(a);
                     expect(a.value.indexOf('_')).toBe(-1);
                     expect(a.value.indexOf('-')).toBeGreaterThan(0);
                     done()
@@ -106,71 +104,54 @@ exports.defineAutoTests = function () {
         });
 
         describe("dateToString", function () {
+            var checkDateToString = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.dateToString).toBeDefined();
                 expect(typeof navigator.globalization.dateToString == 'function').toBe(true);
             });
             it("globalization.spec.5 dateToString using default options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.dateToString(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkDateToString(a);
                     done();
                 }, fail.bind(null, done));
             });
             it("globalization.spec.6 dateToString using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.dateToString(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkDateToString(a);
                     done();
                 }, fail.bind(null, done),
                 { formatLength: 'short', selector: 'date' });
             });
             it("globalization.spec.7 dateToString using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.dateToString(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkDateToString(a);
                     done();
                 }, fail.bind(null, done),
                 { formatLength: 'full', selector: 'date' });
             });
             it("globalization.spec.8 dateToString using formatLength=medium and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.dateToString(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkDateToString(a);
                     done();
                 }, fail.bind(null, done),
                 { formatLength: 'medium' });
             });
             it("globalization.spec.9 dateToString using formatLength=long and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.dateToString(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkDateToString(a);
                     done();
                 }, fail.bind(null, done),
                 { formatLength: 'long' });
             });
             it("globalization.spec.10 dateToString using formatLength=full and selector=date and time(default) options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.dateToString(new Date(), function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkDateToString(a);
                     done();
                 }, fail.bind(null, done),
                 { formatLength: 'full' });
@@ -178,34 +159,37 @@ exports.defineAutoTests = function () {
         });
 
         describe("stringToDate", function () {
+            var checkStringToDate = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.year).toBeDefined();
+                expect(typeof a.year).toBe('number');
+                expect(a.year >= 0 && a.year <= 9999).toBe(true);
+                expect(a.month).toBeDefined();
+                expect(typeof a.month).toBe('number');
+                expect(a.month >= 0 && a.month <= 11).toBe(true);
+                expect(a.day).toBeDefined();
+                expect(typeof a.day).toBe('number');
+                expect(a.day >= 1 && a.day <= 31).toBe(true);
+                expect(a.hour).toBeDefined();
+                expect(typeof a.hour).toBe('number');
+                expect(a.hour >= 0 && a.hour <= 23).toBe(true);
+                expect(a.minute).toBeDefined();
+                expect(typeof a.minute).toBe('number');
+                expect(a.minute >= 0 && a.minute <= 59).toBe(true);
+                expect(a.second).toBeDefined();
+                expect(typeof a.second).toBe('number');
+                expect(a.second >= 0 && a.second <= 59).toBe(true);
+                expect(a.millisecond).toBeDefined();
+                expect(typeof a.millisecond).toBe('number');
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.stringToDate).toBeDefined();
                 expect(typeof navigator.globalization.stringToDate == 'function').toBe(true);
             });
             it("globalization.spec.12 stringToDate using default options, success callback should be called with a Properties object", function (done) {
                 var win = function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.year).toBeDefined();
-                    expect(typeof a.year).toBe('number');
-                    expect(a.year >= 0 && a.year <= 9999).toBe(true);
-                    expect(a.month).toBeDefined();
-                    expect(typeof a.month).toBe('number');
-                    expect(a.month >= 0 && a.month <= 11).toBe(true);
-                    expect(a.day).toBeDefined();
-                    expect(typeof a.day).toBe('number');
-                    expect(a.day >= 1 && a.day <= 31).toBe(true);
-                    expect(a.hour).toBeDefined();
-                    expect(typeof a.hour).toBe('number');
-                    expect(a.hour >= 0 && a.hour <= 23).toBe(true);
-                    expect(a.minute).toBeDefined();
-                    expect(typeof a.minute).toBe('number');
-                    expect(a.minute >= 0 && a.minute <= 59).toBe(true);
-                    expect(a.second).toBeDefined();
-                    expect(typeof a.second).toBe('number');
-                    expect(a.second >= 0 && a.second <= 59).toBe(true);
-                    expect(a.millisecond).toBeDefined();
-                    expect(typeof a.millisecond).toBe('number');
+                    checkStringToDate(a);
                     done();
                 };
 
@@ -215,28 +199,7 @@ exports.defineAutoTests = function () {
             });
             it("globalization.spec.13 stringToDate using formatLength=short and selector=date options, success callback should be called with a Properties object", function (done) {
                 var win = function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.year).toBeDefined();
-                    expect(typeof a.year).toBe('number');
-                    expect(a.year >= 0 && a.year <= 9999).toBe(true);
-                    expect(a.month).toBeDefined();
-                    expect(typeof a.month).toBe('number');
-                    expect(a.month >= 0 && a.month <= 11).toBe(true);
-                    expect(a.day).toBeDefined();
-                    expect(typeof a.day).toBe('number');
-                    expect(a.day >= 1 && a.day <= 31).toBe(true);
-                    expect(a.hour).toBeDefined();
-                    expect(typeof a.hour).toBe('number');
-                    expect(a.hour >= 0 && a.hour <= 23).toBe(true);
-                    expect(a.minute).toBeDefined();
-                    expect(typeof a.minute).toBe('number');
-                    expect(a.minute >= 0 && a.minute <= 59).toBe(true);
-                    expect(a.second).toBeDefined();
-                    expect(typeof a.second).toBe('number');
-                    expect(a.second >= 0 && a.second <= 59).toBe(true);
-                    expect(a.millisecond).toBeDefined();
-                    expect(typeof a.millisecond).toBe('number');
+                    checkStringToDate(a);
                     done();
                 };
 
@@ -246,28 +209,7 @@ exports.defineAutoTests = function () {
             });
             it("globalization.spec.14 stringToDate using formatLength=full and selector=date options, success callback should be called with a Properties object", function (done) {
                 var win = function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.year).toBeDefined();
-                    expect(typeof a.year).toBe('number');
-                    expect(a.year >= 0 && a.year <= 9999).toBe(true);
-                    expect(a.month).toBeDefined();
-                    expect(typeof a.month).toBe('number');
-                    expect(a.month >= 0 && a.month <= 11).toBe(true);
-                    expect(a.day).toBeDefined();
-                    expect(typeof a.day).toBe('number');
-                    expect(a.day >= 1 && a.day <= 31).toBe(true);
-                    expect(a.hour).toBeDefined();
-                    expect(typeof a.hour).toBe('number');
-                    expect(a.hour >= 0 && a.hour <= 23).toBe(true);
-                    expect(a.minute).toBeDefined();
-                    expect(typeof a.minute).toBe('number');
-                    expect(a.minute >= 0 && a.minute <= 59).toBe(true);
-                    expect(a.second).toBeDefined();
-                    expect(typeof a.second).toBe('number');
-                    expect(a.second >= 0 && a.second <= 59).toBe(true);
-                    expect(a.millisecond).toBeDefined();
-                    expect(typeof a.millisecond).toBe('number');
+                    checkStringToDate(a);
                     done();
                 };
 
@@ -291,41 +233,33 @@ exports.defineAutoTests = function () {
         });
 
         describe("getDatePattern", function () {
+            var checkDatePattern = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.pattern).toBeDefined();
+                expect(typeof a.pattern).toBe('string');
+                expect(a.pattern.length > 0).toBe(true);
+                expect(a.timezone).toBeDefined();
+                expect(typeof a.timezone).toBe('string');
+                expect(a.timezone.length > 0).toBe(true);
+                expect(a.utc_offset).toBeDefined();
+                expect(typeof a.utc_offset).toBe('number');
+                expect(a.dst_offset).toBeDefined();
+                expect(typeof a.dst_offset).toBe('number');
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.getDatePattern).toBeDefined();
                 expect(typeof navigator.globalization.getDatePattern == 'function').toBe(true);
             });
             it("globalization.spec.17 getDatePattern using default options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDatePattern(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.pattern).toBeDefined();
-                    expect(typeof a.pattern).toBe('string');
-                    expect(a.pattern.length > 0).toBe(true);
-                    expect(a.timezone).toBeDefined();
-                    expect(typeof a.timezone).toBe('string');
-                    expect(a.timezone.length > 0).toBe(true);
-                    expect(a.utc_offset).toBeDefined();
-                    expect(typeof a.utc_offset).toBe('number');
-                    expect(a.dst_offset).toBeDefined();
-                    expect(typeof a.dst_offset).toBe('number');
+                    checkDatePattern(a);
                     done();
                 }, fail.bind(null, done));
             });
             it("globalization.spec.18 getDatePattern using formatLength=medium and selector=date options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDatePattern(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.pattern).toBeDefined();
-                    expect(typeof a.pattern).toBe('string');
-                    expect(a.pattern.length > 0).toBe(true);
-                    expect(a.timezone).toBeDefined();
-                    expect(typeof a.timezone).toBe('string');
-                    expect(a.timezone.length > 0).toBe(true);
-                    expect(a.utc_offset).toBeDefined();
-                    expect(typeof a.utc_offset).toBe('number');
-                    expect(a.dst_offset).toBeDefined();
-                    expect(typeof a.dst_offset).toBe('number');
+                    checkDatePattern(a);
                     done();
                 }, fail.bind(null, done),
                 { formatLength: 'medium', selector: 'date' });
@@ -333,65 +267,48 @@ exports.defineAutoTests = function () {
         });
 
         describe("getDateNames", function () {
+            var checkDateNames = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(a.value instanceof Array).toBe(true);
+                expect(a.value.length > 0).toBe(true);
+                expect(typeof a.value[0]).toBe('string');
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.getDateNames).toBeDefined();
                 expect(typeof navigator.globalization.getDateNames == 'function').toBe(true);
             });
             it("globalization.spec.20 getDateNames using default options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDateNames(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(a.value instanceof Array).toBe(true);
-                    expect(a.value.length > 0).toBe(true);
-                    expect(typeof a.value[0]).toBe('string');
+                    checkDateNames(a);
                     done();
                 }, fail.bind(null, done));
             });
             it("globalization.spec.21 getDateNames using type=narrow and item=days options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDateNames(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(a.value instanceof Array).toBe(true);
-                    expect(a.value.length > 0).toBe(true);
-                    expect(typeof a.value[0]).toBe('string');
+                    checkDateNames(a);
                     done();
                 }, fail.bind(null, done),
                 { type: 'narrow', item: 'days' });
             });
             it("globalization.spec.22 getDateNames using type=narrow and item=months options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDateNames(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(a.value instanceof Array).toBe(true);
-                    expect(a.value.length > 0).toBe(true);
-                    expect(typeof a.value[0]).toBe('string');
+                    checkDateNames(a);
                     done();
                 }, fail.bind(null, done),
                 { type: 'narrow', item: 'months' });
             });
             it("globalization.spec.23 getDateNames using type=wide and item=days options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDateNames(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(a.value instanceof Array).toBe(true);
-                    expect(a.value.length > 0).toBe(true);
-                    expect(typeof a.value[0]).toBe('string');
+                    checkDateNames(a);
                     done();
                 }, fail.bind(null, done),
                 { type: 'wide', item: 'days' });
             });
             it("globalization.spec.24 getDateNames using type=wide and item=months options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getDateNames(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(a.value instanceof Array).toBe(true);
-                    expect(a.value.length > 0).toBe(true);
-                    expect(typeof a.value[0]).toBe('string');
+                    checkDateNames(a);
                     done();
                 }, fail.bind(null, done),
                 { type: 'wide', item: 'months' });
@@ -431,38 +348,33 @@ exports.defineAutoTests = function () {
         });
 
         describe("numberToString", function () {
+            var checkNumberToString = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('string');
+                expect(a.value.length > 0).toBe(true);
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.numberToString).toBeDefined();
                 expect(typeof navigator.globalization.numberToString == 'function').toBe(true);
             });
             it("globalization.spec.30 numberToString using default options, should be called with a Properties object", function (done) {
                 navigator.globalization.numberToString(3.25, function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkNumberToString(a);
                     done();
                 }, fail.bind(null, done));
             });
             it("globalization.spec.31 numberToString using type=percent options, should be called with a Properties object", function (done) {
                 navigator.globalization.numberToString(.25, function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkNumberToString(a);
                     done();
                 }, fail.bind(null, done),
                 { type: 'percent' });
             });
             it("globalization.spec.32 numberToString using type=currency options, should be called with a Properties object", function (done) {
                 navigator.globalization.numberToString(5.20, function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('string');
-                    expect(a.value.length > 0).toBe(true);
+                    checkNumberToString(a);
                     done();
                 }, fail.bind(null, done),
                 { type: 'currency' });
@@ -470,17 +382,20 @@ exports.defineAutoTests = function () {
         });
 
         describe("stringToNumber", function () {
+            var checkStringToNumber = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.value).toBeDefined();
+                expect(typeof a.value).toBe('number');
+                expect(a.value > 0).toBe(true);
+            };
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.stringToNumber).toBeDefined();
                 expect(typeof navigator.globalization.stringToNumber == 'function').toBe(true);
             });
             it("globalization.spec.34 stringToNumber using default options, should be called with a Properties object", function (done) {
                 var win = function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('number');
-                    expect(a.value > 0).toBe(true);
+                    checkStringToNumber(a);
                     done();
                 };
 
@@ -490,11 +405,7 @@ exports.defineAutoTests = function () {
             });
             it("globalization.spec.35 stringToNumber using type=percent options, should be called with a Properties object", function (done) {
                 var win = function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.value).toBeDefined();
-                    expect(typeof a.value).toBe('number');
-                    expect(a.value > 0).toBe(true);
+                    checkStringToNumber(a);
                     done();
                 };
 
@@ -505,82 +416,48 @@ exports.defineAutoTests = function () {
         });
 
         describe("getNumberPattern", function () {
+            var checkNumberPattern = function (a) {
+                expect(a).toBeDefined();
+                expect(typeof a).toBe('object');
+                expect(a.pattern).toBeDefined();
+                expect(typeof a.pattern).toBe('string');
+                expect(a.pattern.length > 0).toBe(true);
+                expect(typeof a.symbol).toBe('string');
+                expect(typeof a.fraction).toBe('number');
+                expect(typeof a.rounding).toBe('number');
+                expect(a.positive).toBeDefined();
+                expect(typeof a.positive).toBe('string');
+                expect(a.positive.length >= 0).toBe(true);
+                expect(a.negative).toBeDefined();
+                expect(typeof a.negative).toBe('string');
+                expect(a.negative.length >= 0).toBe(true);
+                expect(a.decimal).toBeDefined();
+                expect(typeof a.decimal).toBe('string');
+                expect(a.decimal.length > 0).toBe(true);
+                expect(a.grouping).toBeDefined();
+                expect(typeof a.grouping).toBe('string');
+                expect(a.grouping.length > 0).toBe(true);
+            };
+
             it("globalization.spec.1 should exist", function () {
                 expect(typeof navigator.globalization.getNumberPattern).toBeDefined();
                 expect(typeof navigator.globalization.getNumberPattern == 'function').toBe(true);
             });
             it("globalization.spec.37 getNumberPattern using default options, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getNumberPattern(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.pattern).toBeDefined();
-                    expect(typeof a.pattern).toBe('string');
-                    expect(a.pattern.length > 0).toBe(true);
-                    expect(typeof a.symbol).toBe('string');
-                    expect(typeof a.fraction).toBe('number');
-                    expect(typeof a.rounding).toBe('number');
-                    expect(a.positive).toBeDefined();
-                    expect(typeof a.positive).toBe('string');
-                    expect(a.positive.length >= 0).toBe(true);
-                    expect(a.negative).toBeDefined();
-                    expect(typeof a.negative).toBe('string');
-                    expect(a.negative.length >= 0).toBe(true);
-                    expect(a.decimal).toBeDefined();
-                    expect(typeof a.decimal).toBe('string');
-                    expect(a.decimal.length > 0).toBe(true);
-                    expect(a.grouping).toBeDefined();
-                    expect(typeof a.grouping).toBe('string');
-                    expect(a.grouping.length > 0).toBe(true);
+                    checkNumberPattern(a);
                     done();
                 }, fail.bind(null, done));
             });
             it("globalization.spec.38 getNumberPattern using type=percent, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getNumberPattern(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.pattern).toBeDefined();
-                    expect(typeof a.pattern).toBe('string');
-                    expect(a.pattern.length > 0).toBe(true);
-                    expect(typeof a.symbol).toBe('string');
-                    expect(typeof a.fraction).toBe('number');
-                    expect(typeof a.rounding).toBe('number');
-                    expect(a.positive).toBeDefined();
-                    expect(typeof a.positive).toBe('string');
-                    expect(a.positive.length >= 0).toBe(true);
-                    expect(a.negative).toBeDefined();
-                    expect(typeof a.negative).toBe('string');
-                    expect(a.negative.length >= 0).toBe(true);
-                    expect(a.decimal).toBeDefined();
-                    expect(typeof a.decimal).toBe('string');
-                    expect(a.decimal.length > 0).toBe(true);
-                    expect(a.grouping).toBeDefined();
-                    expect(typeof a.grouping).toBe('string');
-                    expect(a.grouping.length > 0).toBe(true);
+                    checkNumberPattern(a);
                     done();
                 }, fail.bind(null, done), { type: 'percent' });
             });
             it("globalization.spec.39 getNumberPattern using type=currency, success callback should be called with a Properties object", function (done) {
                 navigator.globalization.getNumberPattern(function (a) {
-                    expect(a).toBeDefined();
-                    expect(typeof a).toBe('object');
-                    expect(a.pattern).toBeDefined();
-                    expect(typeof a.pattern).toBe('string');
-                    expect(a.pattern.length > 0).toBe(true);
-                    expect(typeof a.symbol).toBe('string');
-                    expect(typeof a.fraction).toBe('number');
-                    expect(typeof a.rounding).toBe('number');
-                    expect(a.positive).toBeDefined();
-                    expect(typeof a.positive).toBe('string');
-                    expect(a.positive.length >= 0).toBe(true);
-                    expect(a.negative).toBeDefined();
-                    expect(typeof a.negative).toBe('string');
-                    expect(a.negative.length >= 0).toBe(true);
-                    expect(a.decimal).toBeDefined();
-                    expect(typeof a.decimal).toBe('string');
-                    expect(a.decimal.length > 0).toBe(true);
-                    expect(a.grouping).toBeDefined();
-                    expect(typeof a.grouping).toBe('string');
-                    expect(a.grouping.length > 0).toBe(true);
+                    checkNumberPattern(a);
                     done();
                 }, fail.bind(null, done), { type: 'currency' });
             });
@@ -614,4 +491,4 @@ exports.defineAutoTests = function () {
             });
         });
     });
-};
\ No newline at end of file
+};


[3/6] git commit: Merge pull request #1 from eweit/ericCdvtest

Posted by pu...@apache.org.
Merge pull request #1 from eweit/ericCdvtest

Added test to complete CB-7064, added tests that check for W3C complianc...

Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/f5d7c8e0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/f5d7c8e0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/f5d7c8e0

Branch: refs/heads/master
Commit: f5d7c8e0dc814d8074b7b69234c47356521813e9
Parents: 9d9f5af 0675cd1
Author: stacic <sm...@us.ibm.com>
Authored: Thu Jul 3 13:13:47 2014 -0400
Committer: stacic <sm...@us.ibm.com>
Committed: Thu Jul 3 13:13:47 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[2/6] git commit: Added test to complete CB-7064, added tests that check for W3C compliance in language tags generated from PreferredLanguage and GetLocale methods

Posted by pu...@apache.org.
Added test to complete CB-7064, added tests that check for W3C compliance in language tags generated from PreferredLanguage and GetLocale methods


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/0675cd15
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/0675cd15
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/0675cd15

Branch: refs/heads/master
Commit: 0675cd15c065326c42d43f575c5c65ba9e29cdf6
Parents: 9d9f5af
Author: Eric Weiterman <ew...@us.ibm.com>
Authored: Wed Jul 2 15:35:40 2014 -0400
Committer: Eric Weiterman <ew...@us.ibm.com>
Committed: Wed Jul 2 15:35:40 2014 -0400

----------------------------------------------------------------------
 test/tests.js | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/0675cd15/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index 22fda7a..3b2df25 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -52,6 +52,18 @@ exports.defineAutoTests = function () {
                 },
                 fail.bind(null, done));
             });
+            it("globalization.spec.4 getPreferredLanguage return string should have hypen", function (done) {
+                navigator.globalization.getPreferredLanguage(function (a) {
+                    expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    expect(a.value.indexOf('_')).toBe(-1);
+                    expect(a.value.indexOf('-')).toBeGreaterThan(0);
+                    done()
+                }, fail.bind(null, done));
+            });
         });
 
         describe("getLocaleName", function () {
@@ -69,6 +81,18 @@ exports.defineAutoTests = function () {
                     done()
                 }, fail.bind(null, done));
             });
+             it("globalization.spec.4 getLocaleName return string should have hypen", function (done) {
+                navigator.globalization.getLocaleName(function (a) {
+                   expect(a).toBeDefined();
+                    expect(typeof a).toBe('object');
+                    expect(a.value).toBeDefined();
+                    expect(typeof a.value).toBe('string');
+                    expect(a.value.length > 0).toBe(true);
+                    expect(a.value.indexOf('_')).toBe(-1);
+                    expect(a.value.indexOf('-')).toBeGreaterThan(0);
+                    done()
+                }, fail.bind(null, done));
+            });
         });
 
         describe('Globalization Constants (window.Globalization)', function () {
@@ -590,5 +614,4 @@ exports.defineAutoTests = function () {
             });
         });
     });
-};
-
+};
\ No newline at end of file