From: Xotic750 Date: Sat, 14 Sep 2013 23:08:20 +0000 (+0200) Subject: Unit tests X-Git-Tag: 2.3.0~43^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F1087%2Fhead;p=thirdparty%2Fmoment.git Unit tests --- diff --git a/test/moment/normalizeUnits.js b/test/moment/normalizeUnits.js new file mode 100644 index 000000000..3ddc65343 --- /dev/null +++ b/test/moment/normalizeUnits.js @@ -0,0 +1,33 @@ +/*global require, exports */ + +var moment = require("../../moment"); + +exports.normalizeUnits = { + "normalize units" : function (test) { + test.expect(45); + var fullKeys = ["year", "month", "isoweek", "week", "day", "hour", "minute", "second", "millisecond"], + aliases = ["y", "M", "W", "w", "d", "h", "m", "s", "ms"], + length = fullKeys.length, + fullKey, + fullKeyCaps, + fullKeyPlural, + fullKeyCapsPlural, + alias, + index; + + for (index = 0; index < length; index += 1) { + fullKey = fullKeys[index]; + fullKeyCaps = fullKey.toUpperCase(); + fullKeyPlural = fullKey + "s"; + fullKeyCapsPlural = fullKeyCaps + "s"; + alias = aliases[index]; + test.equal(moment.normalizeUnits(fullKey), fullKey, "Testing full key " + fullKey); + test.equal(moment.normalizeUnits(fullKeyCaps), fullKey, "Testing full key capitalised " + fullKey); + test.equal(moment.normalizeUnits(fullKeyPlural), fullKey, "Testing full key plural " + fullKey); + test.equal(moment.normalizeUnits(fullKeyCapsPlural), fullKey, "Testing full key capitalised and plural " + fullKey); + test.equal(moment.normalizeUnits(alias), fullKey, "Testing alias " + fullKey); + } + + test.done(); + } +};