Skip to content

Commit e085a6f

Browse files
committed
Renamed wordSep setting to wordSeparator and added tests
1 parent d11a9cc commit e085a6f

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

jquery.timeago.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
months: "%d months",
4646
year: "about a year",
4747
years: "%d years",
48-
wordSep: " ",
48+
wordSeparator: " ",
4949
numbers: []
5050
}
5151
},
@@ -84,7 +84,7 @@
8484
years < 2 && substitute($l.year, 1) ||
8585
substitute($l.years, Math.floor(years));
8686

87-
return $.trim([prefix, words, suffix].join($l.wordSep));
87+
return $.trim([prefix, words, suffix].join($l.wordSeparator));
8888
},
8989
parse: function(iso8601) {
9090
var s = $.trim(iso8601);

test/index.html

+9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ <h2>Settings</h2>
130130
<li><abbr id="testYoungOldSettings1" class="toyoungold" title="504576000"></abbr> [5840 days]</li>
131131
<li><abbr id="testYoungOldSettings2" class="toyoungold" title="2018304000"></abbr> [23360 days]</li>
132132

133+
<li><abbr id="testNoSpaces1" class="nospaces" title="120"></abbr> [120 sec]</li>
134+
133135
<li><abbr id="testLatinSettings1" class="tolatin" title="-7200"></abbr> [-120 min]</li>
134136
<li><abbr id="testLatinSettings2" class="tolatin" title="-60"></abbr> [-60 sec]</li>
135137
<li><abbr id="testLatinSettings3" class="tolatin" title="-30"></abbr> [-30 sec]</li>
@@ -230,6 +232,9 @@ <h2>Settings</h2>
230232
loadYoungOldYears();
231233
$("abbr.toyoungold").each(toWords);
232234

235+
loadNoSpaces();
236+
$("abbr.nospaces").each(toWords);
237+
233238
loadPigLatin();
234239
$("abbr.tolatin").each(toWords);
235240

@@ -508,6 +513,10 @@ <h2>Settings</h2>
508513
ok($("#testNumbersSettings2").html().match(/^nine minutes/), "Settings correctly applied");
509514
ok($("#testNumbersSettings3").html().match(/^10 minutes/), "Settings correctly applied");
510515
});
516+
517+
test("wordSeparator", function () {
518+
ok($("#testNoSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
519+
});
511520
})(jQuery);
512521
//]]>
513522
</script>

test/test_helpers.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ function loadPigLatin() {
3636
month: "about-hay a-hay onth-may",
3737
months: "%d onths-may",
3838
year: "about-hay a-hay ear-yay",
39-
years: "%d years-yay"
39+
years: "%d years-yay",
40+
wordSeparator: " "
4041
};
4142
}
4243

@@ -71,7 +72,8 @@ function loadRussian() {
7172
month: "месяц",
7273
months: function(value) { return numpf(value, "%d месяц", "%d месяца", "%d месяцев"); },
7374
year: "год",
74-
years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); }
75+
years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); },
76+
wordSeparator: " "
7577
};
7678
})();
7779
}
@@ -95,6 +97,13 @@ function loadMillis() {
9597
};
9698
}
9799

100+
function loadNoSpaces() {
101+
jQuery.extend(jQuery.timeago.settings.strings, {
102+
minutes: "%dminutes",
103+
wordSeparator: ""
104+
});
105+
}
106+
98107
function loadYoungOldYears() {
99108
jQuery.extend(jQuery.timeago.settings.strings, {
100109
years: function(value) { return (value < 21) ? "%d young years" : "%d old years"; }

0 commit comments

Comments
 (0)