ajax-tests.js 638 B

1234567891011121314151617181920212223242526272829303132
  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. });