forked from ExactTarget/fuelux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader-test.js
95 lines (73 loc) · 2.39 KB
/
loader-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false*/
/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
define(function(require){
var $ = require('jquery');
var html = require('text!test/markup/loader-markup.html!strip');
require('bootstrap');
require('fuelux/loader');
module('Fuel UX Loader');
test('should be defined on jquery object', function () {
ok($().loader(), 'loader method is defined');
});
test('should return element', function () {
var $loader = $(html);
ok($loader.loader() === $loader, 'loader is initialized');
});
asyncTest('should play on init', function(){
var $loader = $(html);
$loader.loader();
setTimeout(function(){
start();
ok($loader.attr('data-frame')!==1, 'loader playing on init');
}, 160);
});
asyncTest('pause should function as expected', function(){
var $loader = $(html);
$loader.loader();
$loader.loader('pause');
setTimeout(function(){
start();
equal($loader.attr('data-frame'), 1, 'pause halts frame progression');
}, 160);
});
asyncTest('play should function as expected', function(){
var $loader = $(html);
$loader.loader();
$loader.loader('pause');
$loader.loader('play');
setTimeout(function(){
start();
ok($loader.attr('data-frame')!==1, 'play continues frame progression');
}, 160);
});
asyncTest('reset should function as expected', function(){
var $loader = $(html);
$loader.loader();
setTimeout(function(){
start();
$loader.loader('reset');
equal($loader.attr('data-frame'), 1, 'reset reverts frame to beginning');
}, 160);
});
test('next should function as expected', function(){
var $loader = $(html);
$loader.loader();
$loader.loader('pause');
$loader.loader('next');
equal($loader.attr('data-frame'), 2, 'next increments frame by 1');
});
test('prev should function as expected', function(){
var $loader = $(html);
$loader.loader();
$loader.loader('pause');
$loader.loader('next');
$loader.loader('previous');
equal($loader.attr('data-frame'), 1, 'prev decrements frame by 1');
});
test("should destroy control", function () {
var $el = $(html);
equal(typeof( $el.loader('destroy')) , 'string', 'returns string (markup)');
equal( $el.parent().length, false, 'control has been removed from DOM');
});
});