Added tests for HTML5 <time> element support

This commit is contained in:
Ryan McGeary 2009-10-25 14:18:28 -04:00
parent 39a051940e
commit a5c1424d69
2 changed files with 12 additions and 4 deletions

View file

@ -5,7 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="microid" content="mailto+http:sha1:566841e568e84b46c92d2291b44b836dfddc5c42" /> <meta name="microid" content="mailto+http:sha1:566841e568e84b46c92d2291b44b836dfddc5c42" />
<title>timeago: a jQuery plugin</title> <title>timeago: a jQuery plugin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.timeago.js" type="text/javascript"></script> <script src="jquery.timeago.js" type="text/javascript"></script>
<script src="test/test_helpers.js" type="text/javascript"></script> <script src="test/test_helpers.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -4,7 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- use http://code.jquery.com/jquery-latest.js for the latest jQuery --> <!-- use http://code.jquery.com/jquery-latest.js for the latest jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<!-- http://dev.jquery.com/view/trunk/qunit/testrunner.js --> <!-- http://dev.jquery.com/view/trunk/qunit/testrunner.js -->
<script src="testrunner.js" type="text/javascript"></script> <script src="testrunner.js" type="text/javascript"></script>
@ -24,7 +24,7 @@
<div id="main"> <div id="main">
<h2>Short term</h2> <h2>Short term</h2>
<p>You opened this page <abbr class="loaded timeago testShortTerm">sometime before now</abbr>.</p> <p>You opened this page <abbr class="loaded timeago testShortTerm">(you shouldn't see this)</abbr>.</p>
<p> <p>
This page was last modified <abbr class="modified timeago">sometime before This page was last modified <abbr class="modified timeago">sometime before
@ -66,7 +66,8 @@
<h2>Other formats</h2> <h2>Other formats</h2>
<p>Date only: <abbr class="timeago" title="2008-02-26">(you shouldn't see this)</abbr>.</p> <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>
<h2>Errors</h2> <h2>Errors</h2>
@ -193,6 +194,7 @@
$('abbr.modified').attr('title', iso8601(new Date(document.lastModified))); $('abbr.modified').attr('title', iso8601(new Date(document.lastModified)));
$('abbr.timeago').timeago(); $('abbr.timeago').timeago();
$('time.timeago').timeago();
$('abbr.todate').each(function () { $('abbr.todate').each(function () {
var date = $.timeago.parse(this.title); var date = $.timeago.parse(this.title);
@ -218,6 +220,12 @@
}), 'All text was replaced'); }), 'All text was replaced');
}); });
test('Text in time tag should be replaced', function () {
ok(testElements('time.timeago', function (element) {
return (element.html() !== "(you shouldn't see this)");
}), 'All text was replaced');
});
module('Invalid date'); module('Invalid date');
test('Text in abbr should not be replaced', function () { test('Text in abbr should not be replaced', function () {