Code coverage report for test/base/editing/style.spec.js

# all files / test/base/editing/ style.spec.js

100% Statements 61/61
100% Branches 0/0
100% Functions 12/12
100% Lines 60/60

    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
    791×

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

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

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

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

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

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

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

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

     (function(global){global.wrappers['/Users/lqez/Dev/summernote/test/base/editing/style.spec.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    /**
     * Style.spec.js
     * (c) 2015~ Summernote Team
     * summernote may be freely distributed under the MIT license./
     */
    exports.__esModule = true;
    var chai_1 = require("chai");
    var jquery_1 = require("jquery");
    var range_1 = require("../../../src/js/base/core/range");
    var Style_1 = require("../../../src/js/base/editing/Style");
    var expect = chai_1["default"].expect;
    describe('base:editing.Style', function () {
        var style = new Style_1["default"]();
        describe('styleNodes', function () {
            it('should wrap selected text with span', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p>text</p></div>');
                var $p = $cont.find('p');
                var rng = range_1["default"].create($p[0].firstChild, 0, $p[0].firstChild, 4);
                style.styleNodes(rng);
                expect($cont.html()).to.deep.equal('<p><span>text</span></p>');
            });
            it('should split text and wrap selected text with span', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p>text</p></div>');
                var $p = $cont.find('p');
                var rng = range_1["default"].create($p[0].firstChild, 1, $p[0].firstChild, 3);
                style.styleNodes(rng);
                expect($cont.html()).to.deep.equal('<p>t<span>ex</span>t</p>');
            });
            it('should split text and insert span', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p>text</p></div>');
                var $p = $cont.find('p');
                var rng = range_1["default"].create($p[0].firstChild, 2, $p[0].firstChild, 2);
                style.styleNodes(rng);
                expect($cont.html()).to.deep.equal('<p>te<span></span>xt</p>');
            });
            it('should just return a parent span', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p><span>text</span></p></div>');
                var $span = $cont.find('span');
                var rng = range_1["default"].create($span[0].firstChild, 0, $span[0].firstChild, 4);
                style.styleNodes(rng);
                expect($cont.html()).to.deep.equal('<p><span>text</span></p>');
            });
            it('should wrap each texts with span', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p><b>bold</b><span>span</span></p></div>');
                var $b = $cont.find('b');
                var $span = $cont.find('span');
                var rng = range_1["default"].create($b[0].firstChild, 2, $span[0].firstChild, 2);
                style.styleNodes(rng);
                expect($cont.html()).to.deep.equal('<p><b>bo<span>ld</span></b><span><span>sp</span>an</span></p>');
            });
            it('should wrap each texts with span except not a single blood line', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p><b>bold</b><span>span</span></p></div>');
                var $b = $cont.find('b');
                var $span = $cont.find('span');
                var rng = range_1["default"].create($b[0].firstChild, 2, $span[0].firstChild, 4);
                style.styleNodes(rng);
                expect($cont.html()).to.deep.equal('<p><b>bo<span>ld</span></b><span>span</span></p>');
            });
            it('should expand b tag when providing the expandClosestSibling option', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p>text<b>bold</b></p></div>');
                var $p = $cont.find('p');
                var rng = range_1["default"].create($p[0].firstChild, 0, $p[0].firstChild, 4);
                style.styleNodes(rng, { nodeName: 'B', expandClosestSibling: true });
                expect($cont.html()).to.deep.equal('<p><b>textbold</b></p>');
            });
            it('should not expand b tag when providing the onlyPartialContains option', function () {
                var $cont = jquery_1["default"]('<div class="note-editable"><p>text<b>bold</b></p></div>');
                var $p = $cont.find('p');
                var rng = range_1["default"].create($p[0].firstChild, 0, $p[0].firstChild, 4);
                style.styleNodes(rng, { nodeName: 'B', expandClosestSibling: true, onlyPartialContains: true });
                expect($cont.html()).to.deep.equal('<p><b>text</b><b>bold</b></p>');
            });
        });
    });

    },'test/base/editing/style.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/range":"/Users/lqez/Dev/summernote/src/js/base/core/range.js","../../../src/js/base/editing/Style":"/Users/lqez/Dev/summernote/src/js/base/editing/Style.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 10232 characters]