Code coverage report for test/base/module/Codeview.spec.js

# all files / test/base/module/ Codeview.spec.js

100% Statements 35/35
100% Branches 0/0
100% Functions 7/7
100% Lines 34/34

    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
    481×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    3×
    3×
    3×
    3×

    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/module/Codeview.spec.js']=[function(require,module,exports,__dirname,__filename){ "use strict";
    exports.__esModule = true;
    /**
     * Codeview.spec.js
     * (c) 2015~ Summernote Team
     * summernote may be freely distributed under the MIT license./
     */
    var chai_1 = require("chai");
    var jquery_1 = require("jquery");
    var Context_1 = require("../../../src/js/base/Context");
    var Codeview_1 = require("../../../src/js/base/module/Codeview");
    require("../../../src/js/bs4/settings");
    describe('Codeview', function () {
        var expect = chai_1["default"].expect;
        var options, codeview, context;
        beforeEach(function () {
            options = jquery_1["default"].extend({}, jquery_1["default"].summernote.options);
            options.codeviewFilter = true;
            context = new Context_1["default"](jquery_1["default"]('<div><p>hello</p></div>'), options);
            codeview = new Codeview_1["default"](context);
        });
        it('should toggle codeview mode', function () {
            expect(codeview.isActivated()).to.be["false"];
            codeview.toggle();
            expect(codeview.isActivated()).to.be["true"];
            codeview.toggle();
            expect(codeview.isActivated()).to.be["false"];
        });
        it('should purify malicious codes', function () {
            expect(codeview.purify('<script>alert("summernote");</script>')).to.equalsIgnoreCase('alert("summernote");');
            expect(codeview.purify('<iframe frameborder="0" src="//www.youtube.com/embed/CXgsA98krxA" width="640" height="360" class="note-video-clip"></iframe>')).to.equalsIgnoreCase('<iframe frameborder="0" src="//www.youtube.com/embed/CXgsA98krxA" width="640" height="360" class="note-video-clip"></iframe>');
            expect(codeview.purify('<iframe frameborder="0" src="//www.fake-youtube.com/embed/CXgsA98krxA" width="640" height="360" class="note-video-clip">')).to.equalsIgnoreCase('');
            expect(codeview.purify('<iframe frameborder="0" src="//www.youtube.com/embed/CXgsA98krxA" width="640" height="360" class="note-video-clip"  src  =  "//www.fake-youtube.com/embed/CXgsA98krxA"/>')).to.equalsIgnoreCase('');
        });
        it('should purify can be customized', function () {
            codeview.options = options;
            codeview.options.codeviewIframeFilter = false;
            expect(codeview.purify('<iframe frameborder="0" src="//www.fake-youtube.com/embed/CXgsA98krxA" width="640" height="360" class="note-video-clip">')).to.equalsIgnoreCase('<iframe frameborder="0" src="//www.fake-youtube.com/embed/CXgsA98krxA" width="640" height="360" class="note-video-clip">');
            codeview.options = options;
            codeview.options.codeviewFilterRegex = /\d+/;
            expect(codeview.purify('<script>alert("summernote");</script>')).to.equalsIgnoreCase('<script>alert("summernote");</script>');
            expect(codeview.purify('<span>Tel: 012345678</span>')).to.equalsIgnoreCase('<span>Tel: </span>');
        });
    });

    },'test/base/module/Codeview.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/Context":"/Users/lqez/Dev/summernote/src/js/base/Context.js","../../../src/js/base/module/Codeview":"/Users/lqez/Dev/summernote/src/js/base/module/Codeview.js","../../../src/js/bs4/settings":"/Users/lqez/Dev/summernote/src/js/bs4/settings.js"}];})(this);
    //# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 6172 characters]