smoove_test.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. (function($) {
  2. /*
  3. ======== A Handy Little QUnit Reference ========
  4. http://api.qunitjs.com/
  5. Test methods:
  6. QUnit.module(name, {[setup][ ,teardown]})
  7. test(name, callback)
  8. expect(numberOfAssertions)
  9. stop(increment)
  10. start(decrement)
  11. Test assertions:
  12. ok(value, [message])
  13. equal(actual, expected, [message])
  14. notEqual(actual, expected, [message])
  15. deepEqual(actual, expected, [message])
  16. notDeepEqual(actual, expected, [message])
  17. strictEqual(actual, expected, [message])
  18. notStrictEqual(actual, expected, [message])
  19. throws(block, [expected], [message])
  20. */
  21. QUnit.module('jQuery#smoove', {
  22. // This will run before each test in this module.
  23. beforeEach: function() {
  24. this.elems = $('#qunit-fixture').children();
  25. this.elem1 = $('#t1');
  26. this.elem2 = $('#t2');
  27. }
  28. });
  29. QUnit.test('is chainable', function(assert) {
  30. assert.expect(1);
  31. // Not a bad test to run on collection methods.
  32. assert.equal(this.elems.smoove(), this.elems, 'should be chainable');
  33. });
  34. QUnit.test('adds transition styles', function(assert) {
  35. assert.expect(1);
  36. assert.ok(this.elem1.smoove().attr('style').indexOf('transition') !== -1, 'should add transition styles');
  37. });
  38. QUnit.test('adds parameter styles', function(assert) {
  39. this.elems.smoove({rotate:'180deg'});
  40. this.elem2.data('top', 200000);
  41. $(window).trigger('load');
  42. var done = assert.async();
  43. setTimeout(function(){
  44. assert.ok($('#t2').attr('style').indexOf('rotate(180deg)') !== -1, 'should add parameter styles');
  45. done();
  46. }, 100);
  47. });
  48. QUnit.test('adds data attribute styles', function(assert) {
  49. this.elems.smoove();
  50. this.elem2.data('top', 200000);
  51. $(window).trigger('load');
  52. assert.ok(this.elem2.attr('style').indexOf('translate(10px, 10px)') !== -1, 'should add data-attribute styles');
  53. });
  54. }(jQuery));