2009-07-30 17:58:27 +01:00
<!DOCTYPE html>
2010-06-22 02:25:09 -04:00
< html >
2009-07-30 17:58:27 +01:00
< head >
2013-02-01 17:13:06 -05:00
< meta charset = "utf-8" >
< title > jQuery-Timeago Test Suite< / title >
< link rel = "stylesheet" href = "http://code.jquery.com/qunit/qunit-1.11.0.css" >
2009-07-30 17:58:27 +01:00
< / head >
< body >
2013-02-01 17:13:06 -05:00
< div id = "qunit" > < / div >
< div id = "qunit-fixture" > < / div >
2009-07-30 17:58:27 +01:00
< div id = "main" >
< h2 > Short term< / h2 >
2009-10-25 14:18:28 -04:00
< p > You opened this page < abbr class = "loaded timeago testShortTerm" > (you shouldn't see this)< / abbr > .< / p >
2009-07-30 17:58:27 +01:00
< p >
This page was last modified < abbr class = "modified timeago" > sometime before
now (your browser might not support document.lastModified for local resources)< / abbr > .
< / p >
< h2 > Long term< / h2 >
< p >
Jett was born
< abbr class = "timeago testLongTerm" title = "2008-02-27T00:23:00Z" > (you shouldn't see this)< / abbr >
[from Z].
< / p >
< p >
Jett was born
< abbr class = "timeago testLongTerm" title = "2008-02-26T19:23:00-0500" > (you shouldn't see this)< / abbr >
[from -0500].
< / p >
< p >
Logan was born
< abbr class = "timeago testLongTerm" title = "2005-06-17T23:42:00Z" > (you shouldn't see this)< / abbr >
[from Z].
< / p >
< p >
Logan was born
< abbr class = "timeago testLongTerm" title = "2005-06-17T19:42:00-0400" > (you shouldn't see this)< / abbr >
[from -0400].
< / p >
< p >
Ryan was born
< abbr class = "timeago testLongTerm" title = "1978-12-18T17:17:00Z" > (you shouldn't see this)< / abbr >
[from Z].
< / p >
< p >
Ryan was born
< abbr class = "timeago testLongTerm" title = "1978-12-18T12:17:00-05:00" > (you shouldn't see this)< / abbr >
[from -0500].
< / p >
< h2 > Other formats< / h2 >
2009-10-25 14:18:28 -04:00
< p > Date only (abbr element): < abbr class = "timeago" title = "2008-02-26" > (you shouldn't see this)< / abbr > .< / p >
< p > Date only (time element): < time class = "timeago" datetime = "2008-02-26" > (you shouldn't see this)< / time > .< / p >
2009-10-25 20:22:09 -04:00
< p > Date only (friendly tooltip): < abbr id = "testTooltip" class = "timeago" title = "2008-02-26" > February 26th< / abbr > .< / p >
< p > Date only (default tooltip): < abbr id = "defaultTooltip" class = "timeago" title = "2008-02-26" > < / abbr > .< / p >
2010-06-21 15:09:54 -04:00
< p > Timestsamp (with millis): < abbr class = "timeago" title = "1978-12-18T17:17:00.021Z" > (you shouldn't see this)< / abbr > .< / p >
2009-07-30 17:58:27 +01:00
2012-05-10 10:58:27 +02:00
< p > < time id = "testTimeTitle" class = "timeago" datetime = "2012-05-07T10:06:02+02:00" title = "May 10, 2012 10:06" > May 10, 2012< / time > < / p >
< p > < time id = "testTimeTitle2" class = "timeago" datetime = "2012-05-07T10:06:02+02:00" > May 10, 2012< / time > < / p >
2010-10-27 14:29:24 +02:00
< h2 > Cutoff< / h2 >
< p > Date that is older than cutoff: < abbr class = "timeago cutoff doCutoff" title = "1978-12-18" > (this should be displayed)< / abbr > < / p >
< p > Date that is newer than cutoff: < abbr class = "timeago loaded cutoff dontCutoff" > (you shouldn't see this)< / abbr > < / p >
2009-07-30 17:58:27 +01:00
< h2 > Errors< / h2 >
< p > Bad (letters): < abbr class = "bad timeago" title = "bleh" > (this should be displayed)< / abbr > .< / p >
< p > Bad (blank): < abbr class = "bad timeago" title = "" > (this should be displayed)< / abbr > .< / p >
< p > Bad (missing): < abbr class = "bad timeago" > (this should be displayed)< / abbr > .< / p >
< h2 > Parsing< / h2 >
< p > Ryan was born… < / p >
< ul >
< li > < abbr id = "testParsing1" class = "todate" title = "1978-12-18T17:17:00Z" > < / abbr > [from Z]< / li >
< li > < abbr id = "testParsing2" class = "todate" title = "1978-12-18T17:17:00-00:00" > < / abbr > [from -00:00]< / li >
< li > < abbr id = "testParsing3" class = "todate" title = "1978-12-18T12:17:00-05:00" > < / abbr > [from -05:00]< / li >
< li > < abbr id = "testParsing4" class = "todate" title = "1978-12-18T12:17:00-0500" > < / abbr > [from -0500]< / li >
< li > < abbr id = "testParsing5" class = "todate" title = "1978-12-19T02:17:00+09:00" > < / abbr > [from +09:00]< / li >
< li > < abbr id = "testParsing6" class = "todate" title = "1978-12-19T02:17:00+0900" > < / abbr > [from +0900]< / li >
< li > < abbr id = "testParsing7" class = "todate" title = "1978-12-18 17:17:00" > < / abbr > [from blank TZ]< / li >
2012-06-28 22:44:56 -04:00
< li > < abbr id = "testParsing8" class = "todate" title = "1978-12-18 17:17:00.021Z" > < / abbr > [from Z with milliseconds]< / li >
< li > < abbr id = "testParsing9" class = "todate" title = "1978-12-18 17:17:00.021432Z" > < / abbr > [from Z with microseconds]< / li >
< li > < abbr id = "testParsing10" class = "todate" title = "1978-12-18 17:17:00.0Z" > < / abbr > [from Z with tenths of a second]< / li >
2012-09-01 09:44:07 -04:00
< li > < abbr id = "testParsing11" class = "todate" title = "1978-12-18 17:17:00.02Z" > < / abbr > [from Z with hundreths of a second]< / li >
2009-07-30 17:58:27 +01:00
< / ul >
< h2 > Wording< / h2 >
< ul >
< li > < abbr id = "testWording1" class = "towords" title = "-7200" > < / abbr > [-120 min]< / li >
< li > < abbr id = "testWording2" class = "towords" title = "-60" > < / abbr > [-60 sec]< / li >
< li > < abbr id = "testWording3" class = "towords" title = "-30" > < / abbr > [-30 sec]< / li >
< li > < abbr id = "testWording4" class = "towords" title = "-1" > < / abbr > [-1 sec]< / li >
< li > < abbr id = "testWording5" class = "towords" title = "0" > < / abbr > [0 sec]< / li >
< li > < abbr id = "testWording6" class = "towords" title = "30" > < / abbr > [30 sec]< / li >
< li > < abbr id = "testWording7" class = "towords" title = "45" > < / abbr > [45 sec]< / li >
< li > < abbr id = "testWording8" class = "towords" title = "90" > < / abbr > [90 sec]< / li >
< li > < abbr id = "testWording9" class = "towords" title = "120" > < / abbr > [120 sec]< / li >
< li > < abbr id = "testWording10" class = "towords" title = "2700" > < / abbr > [45 min]< / li >
< li > < abbr id = "testWording11" class = "towords" title = "5340" > < / abbr > [89 min]< / li >
< li > < abbr id = "testWording12" class = "towords" title = "5400" > < / abbr > [90 min]< / li >
< li > < abbr id = "testWording13" class = "towords" title = "7200" > < / abbr > [120 min]< / li >
< li > < abbr id = "testWording14" class = "towords" title = "82800" > < / abbr > [1380 min]< / li >
< li > < abbr id = "testWording15" class = "towords" title = "90000" > < / abbr > [25 hours]< / li >
2012-02-27 14:56:47 +01:00
< li > < abbr id = "testWording16a" class = "towords" title = "147600" > < / abbr > [41 hours]< / li >
< li > < abbr id = "testWording16b" class = "towords" title = "151200" > < / abbr > [42 hours]< / li >
< li > < abbr id = "testWording16c" class = "towords" title = "172800" > < / abbr > [48 hours]< / li >
2009-07-30 17:58:27 +01:00
< li > < abbr id = "testWording17" class = "towords" title = "2505600" > < / abbr > [696 hours]< / li >
< li > < abbr id = "testWording18" class = "towords" title = "2592000" > < / abbr > [30 days]< / li >
< li > < abbr id = "testWording19" class = "towords" title = "16416000" > < / abbr > [190 days]< / li >
< li > < abbr id = "testWording20" class = "towords" title = "31622400" > < / abbr > [366 days]< / li >
2012-02-27 14:56:47 +01:00
< li > < abbr id = "testWording21" class = "towords" title = "62640000" > < / abbr > [725 days]< / li >
< li > < abbr id = "testWording22" class = "towords" title = "94608000" > < / abbr > [1095 days]< / li >
2009-07-30 17:58:27 +01:00
< / ul >
< h2 > Settings< / h2 >
< ul >
2010-02-28 14:24:23 -05:00
< li > < abbr id = "testNumbersSettings1" class = "tonumbers" title = "120" > < / abbr > [2 min]< / li >
< li > < abbr id = "testNumbersSettings2" class = "tonumbers" title = "540" > < / abbr > [9 min]< / li >
< li > < abbr id = "testNumbersSettings3" class = "tonumbers" title = "600" > < / abbr > [10 min]< / li >
2009-07-30 17:58:27 +01:00
< li > < abbr id = "testYoungOldSettings1" class = "toyoungold" title = "504576000" > < / abbr > [5840 days]< / li >
< li > < abbr id = "testYoungOldSettings2" class = "toyoungold" title = "2018304000" > < / abbr > [23360 days]< / li >
2012-03-03 15:15:18 -05:00
< li > < abbr id = "testNoSpaces1" class = "nospaces" title = "120" > < / abbr > [120 sec]< / li >
2012-12-27 15:37:26 +00:00
< li > < abbr id = "testNullSpaces1" class = "nullspaces" title = "120" > < / abbr > [120 sec]< / li >
2012-03-03 15:15:18 -05:00
2009-07-30 17:58:27 +01:00
< li > < abbr id = "testLatinSettings1" class = "tolatin" title = "-7200" > < / abbr > [-120 min]< / li >
< li > < abbr id = "testLatinSettings2" class = "tolatin" title = "-60" > < / abbr > [-60 sec]< / li >
< li > < abbr id = "testLatinSettings3" class = "tolatin" title = "-30" > < / abbr > [-30 sec]< / li >
< li > < abbr id = "testLatinSettings4" class = "tolatin" title = "-1" > < / abbr > [-1 sec]< / li >
< li > < abbr id = "testLatinSettings5" class = "tolatin" title = "0" > < / abbr > [0 sec]< / li >
< li > < abbr id = "testLatinSettings6" class = "tolatin" title = "30" > < / abbr > [30 sec]< / li >
< li > < abbr id = "testLatinSettings7" class = "tolatin" title = "45" > < / abbr > [45 sec]< / li >
< li > < abbr id = "testLatinSettings8" class = "tolatin" title = "90" > < / abbr > [90 sec]< / li >
< li > < abbr id = "testLatinSettings9" class = "tolatin" title = "120" > < / abbr > [120 sec]< / li >
< li > < abbr id = "testLatinSettings10" class = "tolatin" title = "2700" > < / abbr > [45 min]< / li >
< li > < abbr id = "testLatinSettings11" class = "tolatin" title = "5340" > < / abbr > [89 min]< / li >
< li > < abbr id = "testLatinSettings12" class = "tolatin" title = "5400" > < / abbr > [90 min]< / li >
< li > < abbr id = "testLatinSettings13" class = "tolatin" title = "7200" > < / abbr > [120 min]< / li >
< li > < abbr id = "testLatinSettings14" class = "tolatin" title = "82800" > < / abbr > [1380 min]< / li >
< li > < abbr id = "testLatinSettings15" class = "tolatin" title = "90000" > < / abbr > [25 hours]< / li >
< li > < abbr id = "testLatinSettings16" class = "tolatin" title = "172800" > < / abbr > [48 hours]< / li >
< li > < abbr id = "testLatinSettings17" class = "tolatin" title = "2505600" > < / abbr > [696 hours]< / li >
< li > < abbr id = "testLatinSettings18" class = "tolatin" title = "2592000" > < / abbr > [30 days]< / li >
< li > < abbr id = "testLatinSettings19" class = "tolatin" title = "16416000" > < / abbr > [190 days]< / li >
< li > < abbr id = "testLatinSettings20" class = "tolatin" title = "31622400" > < / abbr > [366 days]< / li >
< li > < abbr id = "testLatinSettings21" class = "tolatin" title = "94608000" > < / abbr > [1095 days]< / li >
< li > < abbr id = "testRussianSettings1" class = "torussian" title = "-7200" > < / abbr > [-120 min]< / li >
< li > < abbr id = "testRussianSettings2" class = "torussian" title = "-60" > < / abbr > [-60 sec]< / li >
< li > < abbr id = "testRussianSettings3" class = "torussian" title = "-30" > < / abbr > [-30 sec]< / li >
< li > < abbr id = "testRussianSettings4" class = "torussian" title = "-1" > < / abbr > [-1 sec]< / li >
< li > < abbr id = "testRussianSettings5" class = "torussian" title = "0" > < / abbr > [0 sec]< / li >
< li > < abbr id = "testRussianSettings6" class = "torussian" title = "30" > < / abbr > [30 sec]< / li >
< li > < abbr id = "testRussianSettings7" class = "torussian" title = "45" > < / abbr > [45 sec]< / li >
< li > < abbr id = "testRussianSettings8" class = "torussian" title = "90" > < / abbr > [90 sec]< / li >
< li > < abbr id = "testRussianSettings9" class = "torussian" title = "120" > < / abbr > [120 sec]< / li >
< li > < abbr id = "testRussianSettings10" class = "torussian" title = "2700" > < / abbr > [45 min]< / li >
< li > < abbr id = "testRussianSettings11" class = "torussian" title = "5340" > < / abbr > [89 min]< / li >
< li > < abbr id = "testRussianSettings12" class = "torussian" title = "5400" > < / abbr > [90 min]< / li >
< li > < abbr id = "testRussianSettings13" class = "torussian" title = "7200" > < / abbr > [120 min]< / li >
< li > < abbr id = "testRussianSettings14" class = "torussian" title = "82800" > < / abbr > [1380 min]< / li >
< li > < abbr id = "testRussianSettings15" class = "torussian" title = "90000" > < / abbr > [25 hours]< / li >
< li > < abbr id = "testRussianSettings16" class = "torussian" title = "172800" > < / abbr > [48 hours]< / li >
< li > < abbr id = "testRussianSettings17" class = "torussian" title = "2505600" > < / abbr > [696 hours]< / li >
< li > < abbr id = "testRussianSettings18" class = "torussian" title = "2592000" > < / abbr > [30 days]< / li >
< li > < abbr id = "testRussianSettings19" class = "torussian" title = "16416000" > < / abbr > [190 days]< / li >
< li > < abbr id = "testRussianSettings20" class = "torussian" title = "31622400" > < / abbr > [366 days]< / li >
< li > < abbr id = "testRussianSettings21" class = "torussian" title = "94608000" > < / abbr > [1095 days]< / li >
2010-09-14 21:44:55 -04:00
< li > < abbr id = "testMillisSettings1" class = "tomillis" title = "-7200" > < / abbr > [-120 min]< / li >
< li > < abbr id = "testMillisSettings2" class = "tomillis" title = "-60" > < / abbr > [-60 sec]< / li >
< li > < abbr id = "testMillisSettings3" class = "tomillis" title = "-30" > < / abbr > [-30 sec]< / li >
< li > < abbr id = "testMillisSettings4" class = "tomillis" title = "-1" > < / abbr > [-1 sec]< / li >
< li > < abbr id = "testMillisSettings5" class = "tomillis" title = "0" > < / abbr > [0 sec]< / li >
< li > < abbr id = "testMillisSettings6" class = "tomillis" title = "30" > < / abbr > [30 sec]< / li >
< li > < abbr id = "testMillisSettings7" class = "tomillis" title = "45" > < / abbr > [45 sec]< / li >
< li > < abbr id = "testMillisSettings8" class = "tomillis" title = "90" > < / abbr > [90 sec]< / li >
< li > < abbr id = "testMillisSettings9" class = "tomillis" title = "120" > < / abbr > [120 sec]< / li >
2009-07-30 17:58:27 +01:00
< / ul >
2013-07-30 12:02:17 -04:00
< h2 > Disposal< / h2 >
< p > < abbr class = "disposal disposed" > < / abbr > < / p >
< p > < abbr class = "disposal notDisposed" > < / abbr > < / p >
2009-07-30 17:58:27 +01:00
< / div >
2013-02-01 17:13:06 -05:00
< script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" > < / script >
< script src = "http://code.jquery.com/qunit/qunit-1.11.0.js" > < / script >
< script src = "../jquery.timeago.js" > < / script >
2009-08-15 10:26:12 -04:00
< script src = "test_helpers.js" type = "text/javascript" > < / script >
2009-07-30 17:58:27 +01:00
< script type = "text/javascript" >
//< ![CDATA[
(function ($) {
function testElements(selector, test) {
var elements = $(selector);
var numberOfTests = elements.length;
var numberOfPasses = 0;
elements.each(function () {
if (test($(this))) { numberOfPasses++; }
});
return (numberOfTests === numberOfPasses);
}
function toWords() {
var string = $.timeago.inWords(parseInt(this.title, 10) * 1000);
$(this).text(string);
}
$.timeago.settings.allowFuture = true;
2009-10-25 20:22:09 -04:00
prepareDynamicDates();
2009-07-30 17:58:27 +01:00
2010-10-27 14:29:24 +02:00
$("abbr.timeago").not("abbr.cutoff").timeago();
2010-01-27 17:30:51 -05:00
$("time.timeago").timeago();
2009-07-30 17:58:27 +01:00
2010-10-27 14:29:24 +02:00
loadCutoffSetting();
$("abbr.cutoff").timeago();
unloadCutoffSetting();
2009-10-25 20:22:09 -04:00
var tooltip = $("#testTooltip").data("timeago");
2010-01-27 17:30:51 -05:00
$("abbr.todate").each(function () {
2009-07-30 17:58:27 +01:00
var date = $.timeago.parse(this.title);
2009-07-30 13:28:31 -04:00
$(this).text(date.toUTCString());
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
$("abbr.towords").each(toWords);
2009-07-30 17:58:27 +01:00
2010-02-28 14:24:23 -05:00
loadNumbers();
$("abbr.tonumbers").each(toWords);
unloadNumbers();
2013-07-30 12:02:17 -04:00
setupDisposal();
2009-07-30 17:58:27 +01:00
loadYoungOldYears();
2010-01-27 17:30:51 -05:00
$("abbr.toyoungold").each(toWords);
2009-07-30 17:58:27 +01:00
2012-03-03 15:15:18 -05:00
loadNoSpaces();
$("abbr.nospaces").each(toWords);
2012-12-27 15:37:26 +00:00
loadNullSpaces();
$("abbr.nullspaces").each(toWords);
2009-07-30 17:58:27 +01:00
loadPigLatin();
2010-01-27 17:30:51 -05:00
$("abbr.tolatin").each(toWords);
2009-07-30 17:58:27 +01:00
loadRussian();
2010-01-27 17:30:51 -05:00
$("abbr.torussian").each(toWords);
2009-07-30 17:58:27 +01:00
2010-09-14 21:44:55 -04:00
loadMillis();
$("abbr.tomillis").each(toWords);
2010-01-27 17:30:51 -05:00
module("Valid date");
2009-07-30 17:58:27 +01:00
2010-01-27 17:30:51 -05:00
test("Text in abbr tag should be replaced", function () {
ok(testElements("abbr.timeago", function (element) {
2009-07-30 17:58:27 +01:00
return (element.html() !== "(you shouldn't see this)");
2010-01-27 17:30:51 -05:00
}), "All text was replaced");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("Text in time tag should be replaced", function () {
ok(testElements("time.timeago", function (element) {
2009-10-25 14:18:28 -04:00
return (element.html() !== "(you shouldn't see this)");
2010-01-27 17:30:51 -05:00
}), "All text was replaced");
2009-10-25 14:18:28 -04:00
});
2010-01-27 17:30:51 -05:00
module("Invalid date");
2009-07-30 17:58:27 +01:00
2010-01-27 17:30:51 -05:00
test("Text in abbr should not be replaced", function () {
ok(testElements("abbr.bad", function (element) {
return (element.html() === "(this should be displayed)");
}), "No text was replaced");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
module("Short term");
2009-07-30 17:58:27 +01:00
test("Dates shorter than a minute should be replaced with short term text", function () {
2010-01-27 17:30:51 -05:00
ok(testElements("abbr.testShortTerm", function (element) {
return (element.html() === "less than a minute ago");
}), "All short term dates correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
module("Long term");
2009-07-30 17:58:27 +01:00
2009-07-30 13:28:31 -04:00
test("Dates older than one year should contain the word 'year'", function () {
2010-01-27 17:30:51 -05:00
ok(testElements("abbr.testLongTerm", function (element) {
2009-07-30 17:58:27 +01:00
return (element.html().match(/year/));
2010-01-27 17:30:51 -05:00
}), "All long term dates correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
module("Data object");
2009-10-25 20:22:09 -04:00
test("should set timeago data object", function () {
ok(tooltip, "data set");
ok(tooltip.datetime, "datetime set");
});
2010-10-27 14:29:24 +02:00
module("Cutoff");
test("should not change dates older than cutoff setting", function () {
ok(testElements("abbr.doCutoff", function (element) {
return (element.html() === "(this should be displayed)");
}), "Cutoff setting working fine");
});
test("should change dates newer than cutoff setting", function () {
ok(testElements("abbr.dontCutoff", function (element) {
return (element.html() === "less than a minute ago");
}), "Cutoff setting working fine");
});
2010-01-27 17:30:51 -05:00
module("Tooltip");
2009-10-25 20:22:09 -04:00
test("should set title to original text contents", function () {
ok($("#testTooltip").attr("title") == "February 26th", "correctly set");
});
test("should leave title alone if no text text content", function () {
ok($("#defaultTooltip").attr("title") == "2008-02-26", "correctly set");
});
2012-05-10 10:58:27 +02:00
test("should preserve title in time tags", function () {
ok(($("#testTimeTitle").attr('title') === "May 10, 2012 10:06"), "title preserved")
});
test("should set title in time tags without a title", function () {
ok(($("#testTimeTitle2").attr('title') === "May 10, 2012"), "title set")
});
2010-01-27 17:30:51 -05:00
module("Parsing");
2009-07-30 17:58:27 +01:00
// Note, different browsers behave slightly different
2010-10-26 19:47:33 -04:00
var correctMatch = /Mon, 18 Dec 1978 17:17:00 (GMT|UTC)/;
2009-07-30 17:58:27 +01:00
2010-01-27 17:30:51 -05:00
test("From Z", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing1");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("From -00:00", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing2");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("From -05:00", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing3");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("From -0500", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing4");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("From +09:00", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing5");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("From +0900", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing6");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("From blank TZ", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing7");
var correctMatch = /Mon, 18 Dec 1978 \d\d:17:00 (GMT|UTC)/;
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2009-07-30 17:58:27 +01:00
});
2010-06-21 15:09:54 -04:00
test("From Z with milliseconds", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing8");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2010-06-21 15:09:54 -04:00
});
2010-08-30 09:09:57 -04:00
test("From Z with microseconds", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing9");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2010-08-30 09:09:57 -04:00
});
2012-06-28 22:44:56 -04:00
test("From Z with tenths of a second", function () {
2012-09-01 09:44:07 -04:00
var time = $("#testParsing10");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
});
test("From Z with hundreths of a second", function () {
var time = $("#testParsing11");
ok((time.html().match(correctMatch)), "Correctly parsed " + time.attr("title"));
2012-06-28 23:16:31 +02:00
});
2010-01-27 17:30:51 -05:00
module("Wording");
2009-07-30 17:58:27 +01:00
2010-01-27 17:30:51 -05:00
test("-120 min", function () {
ok(($("#testWording1").html() === "about 2 hours from now"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("-60 sec", function () {
ok(($("#testWording2").html() === "about a minute from now"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("-30 sec", function () {
ok(($("#testWording3").html() === "less than a minute from now"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("-1 sec", function () {
ok(($("#testWording4").html() === "less than a minute from now"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("0 sec", function () {
ok(($("#testWording5").html() === "less than a minute ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("30 sec", function () {
ok(($("#testWording6").html() === "less than a minute ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("45 sec", function () {
ok(($("#testWording7").html() === "about a minute ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("90 sec", function () {
ok(($("#testWording8").html() === "2 minutes ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("120 sec", function () {
ok(($("#testWording9").html() === "2 minutes ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("45 min", function () {
ok(($("#testWording10").html() === "about an hour ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("89 min", function () {
ok(($("#testWording11").html() === "about an hour ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("90 min", function () {
ok(($("#testWording12").html() === "about 2 hours ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("120 min", function () {
ok(($("#testWording13").html() === "about 2 hours ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("1380 min", function () {
ok(($("#testWording14").html() === "about 23 hours ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("25 hours", function () {
ok(($("#testWording15").html() === "a day ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2012-02-27 14:56:47 +01:00
test("41 hour", function () {
ok(($("#testWording16a").html() === "a day ago"), "Correctly parsed");
});
test("42 hours", function () {
ok(($("#testWording16b").html() === "2 days ago"), "Correctly parsed");
});
2010-01-27 17:30:51 -05:00
test("48 hours", function () {
2012-02-27 14:56:47 +01:00
ok(($("#testWording16c").html() === "2 days ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("696 hours", function () {
ok(($("#testWording17").html() === "29 days ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("30 days", function () {
ok(($("#testWording18").html() === "about a month ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("190 days", function () {
ok(($("#testWording19").html() === "6 months ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("366 days", function () {
ok(($("#testWording20").html() === "about a year ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2012-02-27 14:56:47 +01:00
test("725 days", function () {
ok(($("#testWording21").html() === "2 years ago"), "Correctly parsed");
});
2010-01-27 17:30:51 -05:00
test("1095 days", function () {
2012-02-27 14:56:47 +01:00
ok(($("#testWording22").html() === "3 years ago"), "Correctly parsed");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
module("Settings");
2009-07-30 17:58:27 +01:00
2010-01-27 17:30:51 -05:00
test("suffixFromNow", function () {
ok($("#testLatinSettings1").html().match(/omNow-fray$/), "Settings correctly applied");
2010-09-14 21:44:55 -04:00
ok($("#testMillisSettings1").html().match(/from now$/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("suffixAgo", function () {
ok($("#testLatinSettings5").html().match(/ago-hay$/), "Settings correctly applied");
ok($("#testRussianSettings5").html().match(/назад$/), "Settings correctly applied");
2010-09-14 21:44:55 -04:00
ok($("#testMillisSettings5").html().match(/ago/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("prefixFromNow", function () {
ok($("#testRussianSettings2").html().match(/^через/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("seconds", function () {
ok($("#testLatinSettings5").html().match(/^ess-lay an-thay a-hay inute-may/), "Settings correctly applied");
ok($("#testRussianSettings5").html().match(/^меньше минуты/), "Settings correctly applied");
2010-09-14 21:44:55 -04:00
ok($("#testMillisSettings5").html().match(/0 milliseconds/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("minute", function () {
ok($("#testLatinSettings7").html().match(/^about-hay a-hay inute-may/), "Settings correctly applied");
ok($("#testRussianSettings7").html().match(/^минуту/), "Settings correctly applied");
2010-09-14 21:44:55 -04:00
ok($("#testMillisSettings7").html().match(/45000 milliseconds/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("minutes", function () {
ok($("#testLatinSettings8").html().match(/^2 inutes-may/), "Settings correctly applied");
ok($("#testRussianSettings8").html().match(/^2 минуты/), "Settings correctly applied");
// TODO: Test "минута" and "минут"
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("hour", function () {
ok($("#testLatinSettings10").html().match(/^about-hay an-hay hour-hay/), "Settings correctly applied");
ok($("#testRussianSettings10").html().match(/^час/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("hours", function () {
ok($("#testLatinSettings12").html().match(/^about-hay 2 hours-hay/), "Settings correctly applied");
ok($("#testRussianSettings12").html().match(/^2 часа/), "Settings correctly applied");
// TODO: Test "час" and "часов"
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("day", function () {
ok($("#testLatinSettings15").html().match(/^a-hay ay-day/), "Settings correctly applied");
ok($("#testRussianSettings15").html().match(/^день/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("days", function () {
ok($("#testLatinSettings16").html().match(/^2 ays-day/), "Settings correctly applied");
ok($("#testRussianSettings16").html().match(/^2 дня/), "Settings correctly applied");
ok($("#testRussianSettings17").html().match(/^29 дней/), "Settings correctly applied");
// TODO: Test "день"
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("month", function () {
ok($("#testLatinSettings18").html().match(/^about-hay a-hay onth-may/), "Settings correctly applied");
ok($("#testRussianSettings18").html().match(/^месяц/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("months", function () {
ok($("#testLatinSettings19").html().match(/^6 onths-may/), "Settings correctly applied");
ok($("#testRussianSettings19").html().match(/^6 месяцев/), "Settings correctly applied");
// TODO: Test "месяца" and "месяц"
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("year", function () {
ok($("#testLatinSettings20").html().match(/^about-hay a-hay ear-yay/), "Settings correctly applied");
ok($("#testRussianSettings20").html().match(/^год/), "Settings correctly applied");
2009-07-30 17:58:27 +01:00
});
2010-01-27 17:30:51 -05:00
test("years", function () {
ok($("#testYoungOldSettings1").html().match(/^16 young years/), "Settings correctly applied");
ok($("#testYoungOldSettings2").html().match(/^64 old years/), "Settings correctly applied");
ok($("#testLatinSettings21").html().match(/^3 years-yay/), "Settings correctly applied");
ok($("#testRussianSettings21").html().match(/^3 года/), "Settings correctly applied");
// TODO: Test "год" and "лет"
2009-07-30 17:58:27 +01:00
});
2010-02-28 14:24:23 -05:00
test("numbers", function () {
ok($("#testNumbersSettings1").html().match(/^two minutes/), "Settings correctly applied");
ok($("#testNumbersSettings2").html().match(/^nine minutes/), "Settings correctly applied");
ok($("#testNumbersSettings3").html().match(/^10 minutes/), "Settings correctly applied");
});
2012-03-03 15:15:18 -05:00
test("wordSeparator", function () {
ok($("#testNoSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
2012-12-27 15:37:26 +00:00
ok($("#testNullSpaces1").html().match(/^2minutesago$/), "Settings correctly applied");
2012-03-03 15:15:18 -05:00
});
2013-07-30 12:02:17 -04:00
module("Disposal");
asyncTest("disposal", function() {
$(".disposal.disposed").timeago('dispose');
var initialTime_disposedTimeago = $(".disposal.disposed").html();
var initialTime_activeTimeago = $(".disposal.notDisposed").html();
expect(2);
setTimeout(function() {
var updatedTime_disposedTimeago = $(".disposal.disposed").html();
var updatedTime_activeTimeago = $(".disposal.notDisposed").html();
ok(initialTime_disposedTimeago === updatedTime_disposedTimeago, "A disposed timeago didn't get updated");
ok(initialTime_activeTimeago !== updatedTime_activeTimeago, "A non-disposed timeago continued to be updated");
// Dispose still-active timeago
$(".disposal.notDisposed").timeago('dispose');
resetRefreshMillis();
start();
}, 50);
});
2009-07-30 17:58:27 +01:00
})(jQuery);
//]]>
< / script >
< / body >
< / html >