Sha256: 703363fab0010e66b4bea489500546a92014ac8fa59c4abe961a9ab321171ecb

Contents?: true

Size: 954 Bytes

Versions: 86

Compression:

Stored size: 954 Bytes

Contents

module('Utils - escapeMarkup');

var Utils = require('select2/utils');

test('text passes through', function (assert) {
  var text = 'testing this';
  var escaped = Utils.escapeMarkup(text);

  assert.equal(text, escaped);
});

test('html tags are escaped', function (assert) {
  var text = '<script>alert("bad");</script>';
  var escaped = Utils.escapeMarkup(text);

  assert.notEqual(text, escaped);
  assert.equal(escaped.indexOf('<script>'), -1);
});

test('quotes are killed as well', function (assert) {
  var text = 'testin\' these "quotes"';
  var escaped = Utils.escapeMarkup(text);

  assert.notEqual(text, escaped);
  assert.equal(escaped.indexOf('\''), -1);
  assert.equal(escaped.indexOf('"'), -1);
});

test('DocumentFragment options pass through', function (assert) {
  var frag = document.createDocumentFragment();
  frag.innerHTML = '<strong>test</strong>';

  var escaped = Utils.escapeMarkup(frag);

  assert.equal(frag, escaped);
});

Version data entries

86 entries across 86 versions & 7 rubygems

Version Path
card-mod-bootstrap-0.18.1 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.18.0 vendor/select2/tests/utils/escapeMarkup-tests.js
radius-rails-3.1.4 app/assets/components/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.17.0 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.16.0 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.6 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.5 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.4 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.3 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.1.2 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.2.pre1 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.1.1 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.1 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.15.0 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.14.2 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.14.1 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.14.0 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.13.4 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.13.3 vendor/select2/tests/utils/escapeMarkup-tests.js
card-mod-bootstrap-0.13.2 vendor/select2/tests/utils/escapeMarkup-tests.js