No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ajax-tests.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module('Defaults - Ajax');
  2. test('options are merged recursively with default options', function (assert) {
  3. var defaults = require('select2/defaults');
  4. var ajaxDelay = 250;
  5. var ajaxUrl = 'http://www.test.com';
  6. var mergedOptions;
  7. defaults.set('ajax--delay', ajaxDelay);
  8. mergedOptions = defaults.apply({
  9. ajax: {
  10. url: ajaxUrl
  11. }
  12. });
  13. assert.equal(
  14. mergedOptions.ajax.delay,
  15. ajaxDelay,
  16. 'Ajax default options are present on the merged options'
  17. );
  18. assert.equal(
  19. mergedOptions.ajax.url,
  20. ajaxUrl,
  21. 'Ajax provided options are present on the merged options'
  22. );
  23. defaults.reset();
  24. });
  25. test('more than one default option can be changed via set()', function(assert) {
  26. var defaults = require('select2/defaults');
  27. var ajaxDelay = 123;
  28. var dataDataType = 'xml';
  29. defaults.set('ajax--delay', ajaxDelay);
  30. defaults.set('ajax--data-type', dataDataType);
  31. assert.equal(
  32. defaults.defaults.ajax.delay,
  33. ajaxDelay,
  34. 'Both ajax.delay and ajax.dataType present in defaults');
  35. assert.equal(
  36. defaults.defaults.ajax.dataType,
  37. dataDataType,
  38. 'Both ajax.delay and ajax.dataType present in defaults');
  39. defaults.reset();
  40. });