qunit-boilerplate.js 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function () {
  2. 'use strict';
  3. m.deps(window.mock());
  4. // Boilerplate QUnit acceptance test
  5. QUnit.acceptance = function(name, conf) {
  6. var title = document.title;
  7. var wrappedBeforeEach = conf.beforeEach;
  8. conf.beforeEach = function() {
  9. resetTestPromise();
  10. var modal = document.getElementById('modal-mount');
  11. $(modal).off();
  12. if (wrappedBeforeEach) {
  13. wrappedBeforeEach();
  14. }
  15. };
  16. var wrappedAfterEach = conf.afterEach;
  17. conf.afterEach = function(assert) {
  18. var cleaned = assert.async();
  19. var modal = document.getElementById('modal-mount');
  20. wrappedAfterEach();
  21. document.title = title;
  22. $.mockjax.clear();
  23. if(!$(modal).hasClass('in')) {
  24. window.setTimeout(cleaned, 300);
  25. } else {
  26. $(modal).on('hidden.bs.modal', function () {
  27. window.setTimeout(cleaned, 50);
  28. });
  29. }
  30. $(modal).modal('hide');
  31. };
  32. QUnit.module('Acceptance: ' + name, conf);
  33. };
  34. }());