~ubuntu-branches/ubuntu/precise/maas/precise-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/text/tests/functional/text-accentfold-test.js

Tags: 1.2+bzr1373+dfsg-0ubuntu1~12.04.4
* SECURITY UPDATE: failure to authenticate downloaded content (LP: #1039513)
  - debian/patches/CVE-2013-1058.patch: Authenticate downloaded files with
    GnuPG and MD5SUM files. Thanks to Julian Edwards.
  - CVE-2013-1058
* SECURITY UPDATE: configuration options may be loaded from current working
  directory (LP: #1158425)
  - debian/patches/CVE-2013-1057-1-2.patch: Do not load configuration
    options from the current working directory. Thanks to Julian Edwards.
  - CVE-2013-1057

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']});