data-tests.js 868 B

123456789101112131415161718192021222324252627282930313233
  1. module('Options - Attributes');
  2. var Options = require('select2/options');
  3. test('no nesting', function (assert) {
  4. var $test = $('<select data-test="test"></select>');
  5. var options = new Options({}, $test);
  6. assert.equal(options.get('test'), 'test');
  7. });
  8. test('with nesting', function (assert) {
  9. var $test = $('<select data-first--second="test"></select>');
  10. var options = new Options({}, $test);
  11. assert.ok(!(options.get('first-Second')));
  12. assert.equal(options.get('first').second, 'test');
  13. });
  14. test('overrides initialized data', function (assert) {
  15. var $test = $('<select data-override="yes" data-data="yes"></select>');
  16. var options = new Options({
  17. options: 'yes',
  18. override: 'no'
  19. }, $test);
  20. assert.equal(options.get('options'), 'yes');
  21. assert.equal(options.get('override'), 'yes');
  22. assert.equal(options.get('data'), 'yes');
  23. });