~ubuntu-branches/ubuntu/saucy/whoopsie-daisy/saucy

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/tests/text/tests/functional/text-accentfold-test.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-18 13:04:36 UTC
  • Revision ID: package-import@ubuntu.com-20120418130436-vmt93p8fds516lws
Tags: 0.1.32
Fix failing tests on powerpc and ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
YUI.add('text-accentfold-test', function (Y) {
 
2
 
 
3
var AccentFold = Y.Text.AccentFold;
 
4
 
 
5
Y.Test.Runner.add(new Y.Test.Case({
 
6
    name: 'Text.AccentFold',
 
7
 
 
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'));
 
12
    },
 
13
 
 
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'));
 
17
    },
 
18
 
 
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'));
 
24
    },
 
25
 
 
26
    "compare() should return false when folded strings don't match": function () {
 
27
        Y.Assert.isFalse(AccentFold.compare('aaa', 'abc'));
 
28
    },
 
29
 
 
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);
 
34
            return true;
 
35
        }));
 
36
    },
 
37
 
 
38
    // -- filter() -------------------------------------------------------------
 
39
    'filter() should pass accent-folded items to the supplied function': function () {
 
40
        var items = [];
 
41
 
 
42
        AccentFold.filter(['aáa', 'eée'], function (item) {
 
43
            items.push(item);
 
44
        });
 
45
 
 
46
        Y.ArrayAssert.itemsAreSame(['aaa', 'eee'], items);
 
47
    },
 
48
 
 
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';
 
52
        }));
 
53
    },
 
54
 
 
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'));
 
60
    },
 
61
 
 
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'));
 
66
    }
 
67
}));
 
68
 
 
69
}, '@VERSION@', {requires:['text-accentfold', 'test']});