Skip to content

Commit

Permalink
Failing tests for moment#455
Browse files Browse the repository at this point in the history
  • Loading branch information
timrwood committed Oct 2, 2012
1 parent f253f81 commit 0bfa892
Showing 1 changed file with 47 additions and 13 deletions.
60 changes: 47 additions & 13 deletions test/moment/lang.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var moment = require("../../moment");

exports.lang = {
"library getter" : function(test) {
"library getter" : function (test) {
test.expect(4);

moment.lang('en');
Expand All @@ -19,7 +19,7 @@ exports.lang = {
test.done();
},

"library ensure inheritance" : function(test) {
"library ensure inheritance" : function (test) {
test.expect(2);

moment.lang('made-up', {
Expand All @@ -34,7 +34,41 @@ exports.lang = {
test.done();
},

"library langData" : function(test) {
"library ensure inheritance LT L LL LLL LLLL" : function (test) {
test.expect(5);

var lang = 'test-inherit-lt';

moment.lang(lang, {
longDateFormat : {
LT : "-[LT]-",
L : "-[L]-",
LL : "-[LL]-",
LLL : "-[LLL]-",
LLLL : "-[LLLL]-",
},
calendar : {
sameDay : '[sameDay] LT',
nextDay : '[nextDay] L',
nextWeek : '[nextWeek] LL',
lastDay : '[lastDay] LLL',
lastWeek : '[lastWeek] LLLL',
sameElse : 'L'
}
});

moment.lang('es');

test.equal(moment().lang(lang).calendar(), "sameDay -LT-", "Should use instance lang in LT formatting");
test.equal(moment().add('days', 1).lang(lang).calendar(), "nextDay -L-", "Should use instance lang in L formatting");
test.equal(moment().add('days', -1).lang(lang).calendar(), "lastDay -LLL-", "Should use instance lang in LL formatting");
test.equal(moment().add('days', 4).lang(lang).calendar(), "nextWeek -LL-", "Should use instance lang in LLL formatting");
test.equal(moment().add('days', -4).lang(lang).calendar(), "lastWeek -LLLL-", "Should use instance lang in LLLL formatting");

test.done();
},

"library langData" : function (test) {
test.expect(3);
moment.lang('en');

Expand All @@ -45,7 +79,7 @@ exports.lang = {
test.done();
},

"instance lang method" : function(test) {
"instance lang method" : function (test) {
test.expect(3);
moment.lang('en');

Expand All @@ -56,7 +90,7 @@ exports.lang = {
test.done();
},

"instance lang persists with manipulation" : function(test) {
"instance lang persists with manipulation" : function (test) {
test.expect(3);
moment.lang('en');

Expand All @@ -67,7 +101,7 @@ exports.lang = {
test.done();
},

"instance lang persists with cloning" : function(test) {
"instance lang persists with cloning" : function (test) {
test.expect(2);
moment.lang('en');

Expand All @@ -81,7 +115,7 @@ exports.lang = {
test.done();
},

"duration lang method" : function(test) {
"duration lang method" : function (test) {
test.expect(3);
moment.lang('en');

Expand All @@ -92,7 +126,7 @@ exports.lang = {
test.done();
},

"duration lang persists with cloning" : function(test) {
"duration lang persists with cloning" : function (test) {
test.expect(1);
moment.lang('en');

Expand All @@ -103,7 +137,7 @@ exports.lang = {
test.done();
},

"instance lang used with from" : function(test) {
"instance lang used with from" : function (test) {
test.expect(2);
moment.lang('en');

Expand All @@ -116,7 +150,7 @@ exports.lang = {
test.done();
},

"month name callback function" : function(test) {
"month name callback function" : function (test) {
test.expect(3);

function fakeReplace(m, format) {
Expand Down Expand Up @@ -145,7 +179,7 @@ exports.lang = {
},

// the following tests should be removed after the 2.0.0 release as they will be deprecated
"lang accessors on the global object should exist < 2.0.0" : function(test) {
"lang accessors on the global object should exist < 2.0.0" : function (test) {
moment.lang('en');

var a = 'months|monthsShort|monthsParse|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem'.split('|');
Expand All @@ -161,7 +195,7 @@ exports.lang = {
},

// the following tests should be removed after the 2.0.0 release as they will be deprecated
"lang accessors on the global object should change < 2.0.0" : function(test) {
"lang accessors on the global object should change < 2.0.0" : function (test) {
moment.lang('en');

var a = 'months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal'.split('|');
Expand All @@ -183,7 +217,7 @@ exports.lang = {
test.done();
},

"manip lang accessors on the global object < 2.0.0" : function(test) {
"manip lang accessors on the global object < 2.0.0" : function (test) {
test.expect(1);
moment.lang('en');

Expand Down

0 comments on commit 0bfa892

Please sign in to comment.