1
YUI.add('text-accentfold-test', function (Y) {
3
var AccentFold = Y.Text.AccentFold;
5
Y.Test.Runner.add(new Y.Test.Case({
6
name: 'Text.AccentFold',
8
// -- canFold() -------------------------------------------------------
9
'canFold() should return true if any characters can be folded': function () {
10
Y.Assert.isTrue(AccentFold.canFold('aåa'));
11
Y.Assert.isTrue(AccentFold.canFold('AÅA'));
14
'canFold() should return false when no characters can be folded': function () {
15
Y.Assert.isFalse(AccentFold.canFold('aaa'));
16
Y.Assert.isFalse(AccentFold.canFold('AAA'));
19
// -- compare() ------------------------------------------------------------
20
'compare() should return true when folded strings match': function () {
21
Y.Assert.isTrue(AccentFold.compare('aaa', 'aåa'));
22
Y.Assert.isTrue(AccentFold.compare('aaa', 'AÅA'));
23
Y.Assert.isTrue(AccentFold.compare('AAA', 'aåa'));
26
"compare() should return false when folded strings don't match": function () {
27
Y.Assert.isFalse(AccentFold.compare('aaa', 'abc'));
30
'compare() should support a custom comparison function': function () {
31
Y.Assert.isTrue(AccentFold.compare('aåa', 'åaë', function (a, b) {
32
Y.Assert.areSame('aaa', a);
33
Y.Assert.areSame('aae', b);
38
// -- filter() -------------------------------------------------------------
39
'filter() should pass accent-folded items to the supplied function': function () {
42
AccentFold.filter(['aáa', 'eée'], function (item) {
46
Y.ArrayAssert.itemsAreSame(['aaa', 'eee'], items);
49
'filter() should filter the supplied array': function () {
50
Y.ArrayAssert.itemsAreSame(['eée'], AccentFold.filter(['aáa', 'eée'], function (item) {
51
return item === 'eee';
55
// -- fold() ---------------------------------------------------------------
56
'fold() should fold lowercase accented letters to ASCII': function () {
57
Y.Assert.areSame('aaaaaaaaaaaaaaaaaaaaaaaaaa', AccentFold.fold('àåāăąǎǟǡǻȁȃȧḁẚạảấầẩẫậắằẳẵặ'));
58
Y.Assert.areSame('zzzzzz', AccentFold.fold('źżžẑẓẕ'));
59
Y.Assert.areSame('abcd', AccentFold.fold('abcd'));
62
'fold() should fold uppercase accented letters to lowercase ASCII': function () {
63
Y.Assert.areSame('aaaaaaaaaaaaaaaaaaaaaaaa', AccentFold.fold('ÀÅĀĂĄǍǞǠǺȀȂḀẠẢẤẦẨẪẬẮẰẲẴẶ'));
64
Y.Assert.areSame('zzzzzz', AccentFold.fold('ŹŻŽẐẒẔ'));
65
Y.Assert.areSame('abcd', AccentFold.fold('ABCD'));
69
}, '@VERSION@', {requires:['text-accentfold', 'test']});