ui_effects_test.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var uiUtils = require('utils/ui_effects');
  19. describe('utils/ui_effects', function(){
  20. describe('#pulsate()', function(){
  21. beforeEach(function(){
  22. $('body').append('<div id="pulsate-test-dom"></div>');
  23. this.clock = sinon.useFakeTimers();
  24. this.clb = Em.K;
  25. sinon.spy(this, 'clb');
  26. });
  27. afterEach(function () {
  28. this.clb.restore();
  29. });
  30. it('opacity should be 0.2 on 5-th iteration', function() {
  31. var domEl = $('#pulsate-test-dom');
  32. uiUtils.pulsate(domEl, 1000);
  33. this.clock.tick(300);
  34. expect(parseFloat(domEl.css('opacity')).toFixed(1)).to.eql('0.2');
  35. });
  36. it('should call callback at the end', function() {
  37. var domEl = $('#pulsate-test-dom');
  38. uiUtils.pulsate(domEl, 1000, this.clb);
  39. this.clock.tick(2000);
  40. expect(this.clb.calledOnce).to.be.ok;
  41. });
  42. afterEach(function(){
  43. $('#pulsate-test-dom').remove();
  44. this.clock.restore();
  45. });
  46. });
  47. });