From e085a6f28d014958809cb53d2e8352e62b8b00d1 Mon Sep 17 00:00:00 2001 From: Ryan McGeary Date: Sat, 3 Mar 2012 15:15:18 -0500 Subject: [PATCH] Renamed wordSep setting to wordSeparator and added tests --- jquery.timeago.js | 4 ++-- test/index.html | 9 +++++++++ test/test_helpers.js | 13 +++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/jquery.timeago.js b/jquery.timeago.js index a983228..6e9c833 100644 --- a/jquery.timeago.js +++ b/jquery.timeago.js @@ -45,7 +45,7 @@ months: "%d months", year: "about a year", years: "%d years", - wordSep: " ", + wordSeparator: " ", numbers: [] } }, @@ -84,7 +84,7 @@ years < 2 && substitute($l.year, 1) || substitute($l.years, Math.floor(years)); - return $.trim([prefix, words, suffix].join($l.wordSep)); + return $.trim([prefix, words, suffix].join($l.wordSeparator)); }, parse: function(iso8601) { var s = $.trim(iso8601); diff --git a/test/index.html b/test/index.html index edf0a98..55207a7 100644 --- a/test/index.html +++ b/test/index.html @@ -130,6 +130,8 @@
  • [5840 days]
  • [23360 days]
  • +
  • [120 sec]
  • +
  • [-120 min]
  • [-60 sec]
  • [-30 sec]
  • @@ -230,6 +232,9 @@ loadYoungOldYears(); $("abbr.toyoungold").each(toWords); + loadNoSpaces(); + $("abbr.nospaces").each(toWords); + loadPigLatin(); $("abbr.tolatin").each(toWords); @@ -508,6 +513,10 @@ ok($("#testNumbersSettings2").html().match(/^nine minutes/), "Settings correctly applied"); ok($("#testNumbersSettings3").html().match(/^10 minutes/), "Settings correctly applied"); }); + + test("wordSeparator", function () { + ok($("#testNoSpaces1").html().match(/^2minutesago$/), "Settings correctly applied"); + }); })(jQuery); //]]> diff --git a/test/test_helpers.js b/test/test_helpers.js index 6a345e2..b8cf36a 100644 --- a/test/test_helpers.js +++ b/test/test_helpers.js @@ -36,7 +36,8 @@ function loadPigLatin() { month: "about-hay a-hay onth-may", months: "%d onths-may", year: "about-hay a-hay ear-yay", - years: "%d years-yay" + years: "%d years-yay", + wordSeparator: " " }; } @@ -71,7 +72,8 @@ function loadRussian() { month: "месяц", months: function(value) { return numpf(value, "%d месяц", "%d месяца", "%d месяцев"); }, year: "год", - years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); } + years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); }, + wordSeparator: " " }; })(); } @@ -95,6 +97,13 @@ function loadMillis() { }; } +function loadNoSpaces() { + jQuery.extend(jQuery.timeago.settings.strings, { + minutes: "%dminutes", + wordSeparator: "" + }); +} + function loadYoungOldYears() { jQuery.extend(jQuery.timeago.settings.strings, { years: function(value) { return (value < 21) ? "%d young years" : "%d old years"; }