# all files / test/base/core/ lists.spec.js

100% Statements 66/66
100% Branches 0/0
100% Functions 35/35
100% Lines 64/64

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    1051×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×

    2×
    5×

    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×

    1×
    1×
    1×

    1×
    1×

    1×
    1×
    1×

    1×
    3×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    4×

    1×

    1×
    1×
    4×

    1×

    1×
    1×
    1×

    1×
    1×
    1×

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/test/base/core/lists.spec.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    /**
     * lists.spec.js
     * (c) 2013~ Alan Hong
     * summernote may be freely distributed under the MIT license./
     */
    var chai_1 = require("chai");
    var jquery_1 = require("jquery");
    var lists_1 = require("../../../src/js/base/core/lists");
    var expect = chai_1["default"].expect;
    describe('base:core.lists', function () {
        describe('head', function () {
            it('should return the first element', function () {
                expect(lists_1["default"].head([1, 2, 3])).to.be.equal(1);
            });
        });
        describe('last', function () {
            it('should return the last element', function () {
                expect(lists_1["default"].last([1, 2, 3])).to.be.equal(3);
            });
        });
        describe('initial', function () {
            it('should exclude last element', function () {
                expect(lists_1["default"].initial([1, 2, 3])).to.deep.equal([1, 2]);
            });
        });
        describe('tail', function () {
            it('should exclude first element', function () {
                expect(lists_1["default"].tail([1, 2, 3])).to.deep.equal([2, 3]);
            });
        });
        function isEven(num) {
            return num % 2 === 0;
        }
        describe('find', function () {
            it('should return first matched element', function () {
                expect(lists_1["default"].find([1, 2, 3], isEven)).to.be.equal(2);
            });
        });
        describe('all', function () {
            it('should return false if all elements are not even', function () {
                expect(lists_1["default"].all([1, 2, 3], isEven)).to.be["false"];
            });
            it('should return true if all elements are even', function () {
                expect(lists_1["default"].all([2, 4], isEven)).to.be["true"];
            });
        });
        describe('all', function () {
            it('should return false if the element is not contained', function () {
                expect(lists_1["default"].contains([1, 2, 3], 4)).to.be["false"];
            });
            it('should return true if the element is contained', function () {
                expect(lists_1["default"].contains([1, 2, 4], 4)).to.be["true"];
            });
        });
        describe('sum', function () {
            it('should return sum of all elements', function () {
                expect(lists_1["default"].sum([1, 2, 3])).to.be.equal(6);
            });
            it('should return sum of all elements iterated', function () {
                var result = lists_1["default"].sum([1, 2, 3], function (v) { return v * 2; });
                expect(result).to.be.equal(12);
            });
        });
        describe('from', function () {
            it('should return an array of childNodes', function () {
                var $cont, $b, $u, $s, $i;
                $cont = jquery_1["default"]('<div><b>b</b><u>u</u><s>s</s><i>i</i></div>'); // busi
                $b = $cont.find('b');
                $u = $cont.find('u');
                $s = $cont.find('s');
                $i = $cont.find('i');
                expect(lists_1["default"].from($cont[0].childNodes)).to.deep.equal([$b[0], $u[0], $s[0], $i[0]]);
            });
        });
        describe('clusterBy', function () {
            it('should cluster by equality 1', function () {
                var aaClustered = lists_1["default"].clusterBy([1, 1, 2, 2, 3], function (itemA, itemB) {
                    return itemA === itemB;
                });
                expect(aaClustered).to.deep.equal([[1, 1], [2, 2], [3]]);
            });
            it('should cluster by equality 2', function () {
                var aaClustered = lists_1["default"].clusterBy([1, 2, 2, 1, 3], function (itemA, itemB) {
                    return itemA === itemB;
                });
                expect(aaClustered).to.deep.equal([[1], [2, 2], [1], [3]]);
            });
        });
        describe('compact', function () {
            it('should remove all elements has false value', function () {
                expect(lists_1["default"].compact([0, 1, false, 2, '', 3])).to.deep.equal([1, 2, 3]);
            });
        });
        describe('unique', function () {
            it('should return duplicate-free version of array', function () {
                expect(lists_1["default"].unique([1, 2, 3, 3, 2, 1])).to.deep.equal([1, 2, 3]);
            });
        });
    });

    },'test/base/core/lists.spec.js',{"chai":"/Users/lqez/Dev/summernote/node_modules/chai/index.js","jquery":"/Users/lqez/Dev/summernote/node_modules/jquery/dist/jquery.js","../../../src/js/base/core/lists":"/Users/lqez/Dev/summernote/src/js/base/core/lists.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,