Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
262 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>jQuery Plugin Test Suite</title> | ||
<link rel="stylesheet" href="vendor/qunit.css" media="screen"> | ||
<script src="vendor/qunit.js"></script> | ||
<script src="vendor/jquery.min.js"></script> | ||
<script src="../../lib/int17.js"></script> | ||
<script src="../../lib/jquery.int17.js"></script> | ||
<script src="../helpers.js"></script> | ||
<script src="jquery_test.js"></script> | ||
</head> | ||
<body> | ||
<h1 id="qunit-header">jQuery Plugin Test Suite</h1> | ||
<h2 id="qunit-banner"></h2> | ||
<div id="qunit-testrunner-toolbar"></div> | ||
<h2 id="qunit-userAgent"></h2> | ||
<ol id="qunit-tests"></ol> | ||
<div id="qunit-fixture"></div> | ||
<div id="int17" style="display: none"> | ||
<div class="test1"> | ||
<a class="e1" i18n-content="test1"></a> | ||
<a class="e2" data-i18n-content="test2"></a> | ||
<a class="e3" i18n-subs="a1;a2" i18n-content="test2"></a> | ||
<a class="e4" data-i18n-subs="a1;a2" i18n-values="title:test2;.style.direction:dir;.innerHTML:test4"></a> | ||
<select class="e5" i18n-options="testOpt1:-1;testOpt2;testOpt3"></select> | ||
</div> | ||
<div class="test2"> | ||
<a class="e1" data-i18n-content="test1"></a> | ||
<a class="e2" i18n-content="test2"></a> | ||
<a class="e3" data-i18n-subs="a1;a2" data-i18n-content="test2"></a> | ||
<a class="e4" i18n-subs="a1;a2" data-i18n-values="title:test2;.style.direction:dir;.innerHTML:test4"></a> | ||
<select class="e5" data-i18n-options="testOpt1:-1;testOpt2;testOpt3"></select> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
'use strict'; | ||
|
||
asyncTest('jQuery:callback', 12, function (test) { | ||
var opts = { | ||
clean: true | ||
, encoding: 'UTF-8' | ||
, extension: '.js' | ||
, fallback: false | ||
, fileName: 'msgs' | ||
, folders: true | ||
, ignoreCase: false | ||
, locale: ['fr', 'BE'] | ||
, path: '../fixtures/locales3' | ||
}; | ||
$.int17(opts, function (err, inst) { | ||
test.ok(!err, 'Error was thrown'); | ||
test.ok(inst, 'Instance was not created'); | ||
test.ok(inst.messenger.messages, 'No messages were loaded'); | ||
helpers.strictContains(test, inst.messenger, opts, 'Options were not set correctly'); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery:callback:int17', 2, function (test) { | ||
var inst = int17.create() | ||
, opts = { | ||
extension: '.js' | ||
, fileName: 'msgs' | ||
, folders: true | ||
, locale: ['fr', 'BE'] | ||
, path: '../fixtures/locales3' | ||
}; | ||
inst.initSync(opts); | ||
$.int17({ int17: inst }, function (err, i18n) { | ||
test.ok(!err, 'Error was thrown'); | ||
test.strictEqual(i18n, inst, 'Instance was not reused'); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery:callback:int17:name', 2, function (test) { | ||
var inst = int17.create('foo') | ||
, opts = { | ||
extension: '.js' | ||
, fileName: 'msgs' | ||
, folders: true | ||
, locale: ['fr', 'BE'] | ||
, path: '../fixtures/locales3' | ||
}; | ||
inst.initSync(opts); | ||
$.int17({ int17: 'foo' }, function (err, i18n) { | ||
test.ok(!err, 'Error was thrown'); | ||
test.strictEqual(i18n, inst, 'Instance was not reused'); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery:deferred', 11, function (test) { | ||
var opts = { | ||
clean: true | ||
, encoding: 'UTF-8' | ||
, extension: '.js' | ||
, fallback: false | ||
, fileName: 'msgs' | ||
, folders: true | ||
, ignoreCase: false | ||
, locale: ['fr', 'BE'] | ||
, path: '../fixtures/locales3' | ||
}; | ||
$.int17(opts).done(function (inst) { | ||
test.ok(inst, 'Instance was not created'); | ||
test.ok(inst.messenger.messages, 'No messages were loaded'); | ||
helpers.strictContains(test, inst.messenger, opts, 'Options were not set correctly'); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery:deferred:int17', 1, function (test) { | ||
var inst = int17.create() | ||
, opts = { | ||
extension: '.js' | ||
, fileName: 'msgs' | ||
, folders: true | ||
, locale: ['fr', 'BE'] | ||
, path: '../fixtures/locales3' | ||
}; | ||
inst.initSync(opts); | ||
$.int17({ int17: inst }).done(function (i18n) { | ||
test.strictEqual(i18n, inst, 'Instance was not reused'); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery:deferred:int17:name', 1, function (test) { | ||
var inst = int17.create('foo') | ||
, opts = { | ||
extension: '.js' | ||
, fileName: 'msgs' | ||
, folders: true | ||
, locale: ['fr', 'BE'] | ||
, path: '../fixtures/locales3' | ||
}; | ||
inst.initSync(opts); | ||
$.int17({ int17: 'foo' }).done(function (i18n) { | ||
test.strictEqual(i18n, inst, 'Instance was not reused'); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery.fn', 5, function (test) { | ||
var reset = helpers.resetter('.test1'); | ||
$.int17({ locale: 'en', path: '../fixtures/locales1' }).done(function () { | ||
$('#int17 .test1').int17(); | ||
helpers.htmlEqual(test, '.test1 .e1', '<a class="e1" i18n-content="test1">test1m</a>'); | ||
helpers.htmlEqual(test, '.test1 .e2', '<a class="e2" data-i18n-content="test2">' + | ||
'test2m $1 $1 $2</a>'); | ||
helpers.htmlEqual(test, '.test1 .e3', '<a class="e3" i18n-subs="a1;a2" i18n-content="test2">' + | ||
'test2m a1 a1 a2</a>'); | ||
helpers.htmlEqual(test, '.test1 .e4', '<a class="e4" data-i18n-subs="a1;a2" ' + | ||
'i18n-values="title:test2;.style.direction:dir;.innerHTML:test4" title="test2m a1 a1 a2" ' + | ||
'style="direction: ltr; "><span i18n-content="test1">test1m</span></a>'); | ||
helpers.htmlEqual(test, '.test1 .e5', '<select class="e5" ' + | ||
'i18n-options="testOpt1:-1;testOpt2;testOpt3"><option value="-1">option1</option>' + | ||
'<option>option2</option><option>option3</option></select>'); | ||
reset(); | ||
start(); | ||
}); | ||
}); | ||
|
||
asyncTest('jQuery.fn:clean', 5, function (test) { | ||
var reset = helpers.resetter('.test2'); | ||
$.int17({ clean: true, locale: 'en', path: '../fixtures/locales1' }).done(function () { | ||
$('#int17 .test2').int17(); | ||
helpers.htmlEqual(test, '.test2 .e1', '<a class="e1">test1m</a>'); | ||
helpers.htmlEqual(test, '.test2 .e2', '<a class="e2">test2m $1 $1 $2</a>'); | ||
helpers.htmlEqual(test, '.test2 .e3', '<a class="e3">test2m a1 a1 a2</a>'); | ||
helpers.htmlEqual(test, '.test2 .e4', '<a class="e4" title="test2m a1 a1 a2" ' + | ||
'style="direction: ltr; "><span>test1m</span></a>'); | ||
helpers.htmlEqual(test, '.test2 .e5', '<select class="e5"><option value="-1">option1</option>' + | ||
'<option>option2</option><option>option3</option></select>'); | ||
reset(); | ||
start(); | ||
}); | ||
}); |