ElggSpinnerTest.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. define(function(require) {
  2. var spinner = require('elgg/spinner');
  3. var elgg = require('elgg');
  4. var visible_selector = 'body.elgg-spinner-active';
  5. describe("elgg/spinner", function() {
  6. beforeEach(function () {
  7. spinner.stop();
  8. });
  9. it("indicator is in the DOM", function () {
  10. expect($('.elgg-spinner').length).toBe(1);
  11. });
  12. it("start() doesn't add the body class immediately", function() {
  13. expect($(visible_selector).length).toBe(0);
  14. spinner.start();
  15. expect($(visible_selector).length).toBe(0);
  16. });
  17. it("start() adds the body class after 20ms", function(done) {
  18. expect($(visible_selector).length).toBe(0);
  19. spinner.start();
  20. setTimeout(function() {
  21. expect($(visible_selector).length).toBe(1);
  22. done();
  23. }, 25);
  24. });
  25. it("stop() removes the body class", function(done) {
  26. spinner.start();
  27. setTimeout(function() {
  28. expect($(visible_selector).length).toBe(1);
  29. spinner.stop();
  30. expect($(visible_selector).length).toBe(0);
  31. done();
  32. }, 25);
  33. });
  34. });
  35. });