Sha256: 65c98f16a42956ab60013a74f32c2bbb5f218e97d7ad375b1c5a14070a70d0f6

Contents?: true

Size: 1.75 KB

Versions: 73

Compression:

Stored size: 1.75 KB

Contents

module('Selection containers - Placeholders');

var Placeholder = require('select2/selection/placeholder');
var SingleSelection = require('select2/selection/single');

var $ = require('jquery');
var Options = require('select2/options');
var Utils = require('select2/utils');

var SinglePlaceholder = Utils.Decorate(SingleSelection, Placeholder);

var placeholderOptions = new Options({
  placeholder: {
    id: 'placeholder',
    text: 'This is the placeholder'
  }
});

test('normalizing placeholder ignores objects', function (assert) {
  var selection = new SinglePlaceholder(
    $('#qunit-fixture .single'),
    placeholderOptions
  );

  var original = {
    id: 'test',
    text: 'testing'
  };

  var normalized = selection.normalizePlaceholder(original);

  assert.equal(original, normalized);
});

test('normalizing placeholder gives object for string', function (assert) {
  var selection = new SinglePlaceholder(
    $('#qunit-fixture .single'),
    placeholderOptions
  );

  var normalized = selection.normalizePlaceholder('placeholder');

  assert.equal(normalized.id, '');
  assert.equal(normalized.text, 'placeholder');
});


test('text is shown for placeholder option on single', function (assert) {
  var selection = new SinglePlaceholder(
    $('#qunit-fixture .single'),
    placeholderOptions
  );

  var $selection = selection.render();

  selection.update([{
    id: 'placeholder'
  }]);

  assert.equal($selection.text(), 'This is the placeholder');
});

test('placeholder is shown when no options are selected', function (assert) {
  var selection = new SinglePlaceholder(
    $('#qunit-fixture .multiple'),
    placeholderOptions
  );

  var $selection = selection.render();

  selection.update([]);

  assert.equal($selection.text(), 'This is the placeholder');
});

Version data entries

73 entries across 73 versions & 7 rubygems

Version Path
radius-rails-3.1.4 app/assets/components/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.14.2 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.14.1 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.14.0 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.13.4 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.13.3 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.13.2 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.13.1 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.13.0 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.7 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.12.0 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.6 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.5 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.4 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.3 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.2 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.1 vendor/select2/tests/selection/placeholder-tests.js
card-mod-bootstrap-0.11.0 vendor/select2/tests/selection/placeholder-tests.js
card-1.100.0 mod/bootstrap/vendor/select2/tests/selection/placeholder-tests.js
card-1.99.6 mod/bootstrap/vendor/select2/tests/selection/placeholder-tests.js