<commit_before>/**
 * Codeview.spec.js
 * (c) 2015~ Summernote Team
 * summernote may be freely distributed under the MIT license./
 */
import chai from 'chai';
import $ from 'jquery';
import Context from '../../../../src/js/base/Context';
import Codeview from '../../../../src/js/base/module/Codeview';
import '../../../../src/js/bs4/settings';

describe('Codeview', () => {
  var expect = chai.expect;
  var codeview, context;

  beforeEach(() => {
    var options = $.extend({}, $.summernote.options);
    context = new Context($('<div><p>hello</p></div>'), options);
    codeview = new Codeview(context);
  });

  it('should toggle codeview mode', () => {
    expect(codeview.isActivated()).to.be.false;
    codeview.toggle();
    expect(codeview.isActivated()).to.be.true;
    codeview.toggle();
    expect(codeview.isActivated()).to.be.false;
  });
});<commit_msg>Add a test for Codeview purify<commit_after>/**
 * Codeview.spec.js
 * (c) 2015~ Summernote Team
 * summernote may be freely distributed under the MIT license./
 */
import chai from 'chai';
import $ from 'jquery';
import Context from '../../../../src/js/base/Context';
import Codeview from '../../../../src/js/base/module/Codeview';
import '../../../../src/js/bs4/settings';

describe('Codeview', () => {
  var expect = chai.expect;
  var codeview, context;

  beforeEach(() => {
    var options = $.extend({}, $.summernote.options);
    options.codeviewFilter = true;
    context = new Context($('<div><p>hello</p></div>'), options);
    codeview = new Codeview(context);
  });

  it('should toggle codeview mode', () => {
    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', () => {
    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"></iframe>')).to.equalsIgnoreCase(
      ''
    );
  });
});
{'fraction_non_alphanumeric': 0.21520514883346742, 'fraction_numerical': 0.014883346741753822, 'mean_word_length': 3.6485981308411213, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7234583', 'n_tokens_mistral': 833, 'n_tokens_neox': 801, 'n_words': 151}