6 |
--------------------------------------------------------------------------------
/tests/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration
2 | // http://karma-runner.github.io/0.12/config/configuration-file.html
3 | // Generated on 2015-03-07 using
4 | // generator-karma 0.9.0
5 |
6 | module.exports = function(config) {
7 | 'use strict';
8 |
9 | config.set({
10 | // enable / disable watching file and executing tests whenever any file changes
11 | autoWatch: false,
12 |
13 | // base path, that will be used to resolve files and exclude
14 | basePath: '',
15 |
16 | // testing framework to use (jasmine/mocha/qunit/...)
17 | frameworks: ['jasmine'],
18 |
19 | // list of files / patterns to load in the browser
20 | files: [
21 | 'setup-tests.js',
22 | '../scripts/imagesloaded.pkgd.min.js',
23 | '../scripts/hammer.min.js',
24 | '../scripts/sequence.js',
25 | 'spec/*.js'
26 | ],
27 |
28 | // list of files / patterns to exclude
29 | exclude: [
30 | ],
31 |
32 | // web server port
33 | port: 8080,
34 |
35 | // Start these browsers, currently available:
36 | // - Chrome
37 | // - ChromeCanary
38 | // - Firefox
39 | // - Opera
40 | // - Safari (only Mac)
41 | // - PhantomJS
42 | // - IE (only Windows)
43 | browsers: [
44 | 'PhantomJS'
45 | ],
46 |
47 | // Which plugins to enable
48 | plugins: [
49 | 'karma-phantomjs-launcher',
50 | 'karma-jasmine'
51 | ],
52 |
53 | // Continuous Integration mode
54 | // if true, it capture browsers, run tests and exit
55 | singleRun: false,
56 |
57 | colors: true,
58 |
59 | // level of logging
60 | // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
61 | logLevel: config.LOG_INFO,
62 |
63 | // Uncomment the following lines if you are using grunt's server to run the tests
64 | // proxies: {
65 | // '/': 'http://localhost:9000/'
66 | // },
67 | // URL root prevent conflicts with the site root
68 | // urlRoot: '_karma_'
69 | });
70 | };
71 |
--------------------------------------------------------------------------------
/tests/setup-tests.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Append a Sequence element to the DOM for testing and set up other functions
3 | * required for testing
4 | */
5 |
6 | var done = function() {};
7 |
8 | var appendSequence,
9 | resetSequence,
10 | initSequence;
11 |
12 | appendSequence = function() {
13 |
14 | var sequenceHtml = '
Box 1
Box 2
Box 3
';
15 |
16 | document.body.innerHTML = sequenceHtml;
17 | };
18 |
19 | resetSequence = function(sequence) {
20 | sequence.destroy();
21 | };
22 |
23 | removeSequence = function() {
24 | var testContainer = document.getElementById("test-container");
25 | testContainer.parentNode.removeChild(testContainer);
26 | };
27 |
28 | initSequence = function(options) {
29 |
30 | if (options === undefined) {
31 | options = {};
32 | }
33 |
34 | var sequenceElement = document.getElementById("sequence"),
35 | mySequence = sequence(sequenceElement, options);
36 |
37 | return mySequence;
38 | };
39 |
--------------------------------------------------------------------------------
/tests/spec/animation-fallback.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.animationFallback
3 | */
4 |
--------------------------------------------------------------------------------
/tests/spec/animation.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.animation
3 | */
4 |
5 | describe("animation.getPropertySupport()", function() {
6 |
7 | var sequence;
8 |
9 | // Set up Sequence and wait for it to be ready
10 | beforeAll(function(done) {
11 |
12 | appendSequence();
13 |
14 | sequence = initSequence();
15 |
16 | sequence.ready = function() {
17 | done();
18 | };
19 |
20 | });
21 |
22 | afterAll(function(done) {
23 | removeSequence();
24 | SetTimeout(function() {
25 | resetSequence(sequence);
26 | done();
27 | }, 500);
28 | });
29 |
30 | it("should return a list of properties and whether the browser supports them", function() {
31 | expect(sequence.animation.getPropertySupport()).toEqual(jasmine.any(Object));
32 | });
33 | });
34 |
35 | describe("animation.requiresFallbackMode()", function() {
36 |
37 | var sequence;
38 |
39 | // Set up Sequence and wait for it to be ready
40 | beforeAll(function(done) {
41 |
42 | appendSequence();
43 |
44 | sequence = initSequence();
45 |
46 | sequence.ready = function() {
47 | done();
48 | };
49 | });
50 |
51 | afterAll(function(done) {
52 | removeSequence();
53 | SetTimeout(function() {
54 | resetSequence(sequence);
55 | done();
56 | }, 500);
57 | });
58 |
59 | it("should put Sequence in fallbackMode if transitions aren't supported", function() {
60 |
61 | var propertySupport = {
62 | transitions: false
63 | };
64 | expect(sequence.animation.requiresFallbackMode(propertySupport)).toEqual(true);
65 | });
66 | });
67 |
68 | describe("animation.getReversePhaseDelay()", function() {
69 |
70 | var sequence;
71 |
72 | // Set up Sequence and wait for it to be ready
73 | beforeAll(function(done) {
74 |
75 | appendSequence();
76 |
77 | sequence = initSequence();
78 |
79 | sequence.ready = function() {
80 | done();
81 | };
82 | });
83 |
84 | afterAll(function(done) {
85 | removeSequence();
86 | SetTimeout(function() {
87 | resetSequence(sequence);
88 | done();
89 | }, 500);
90 | });
91 |
92 |
93 | it("should return a next reversePhaseDelay of 1000 when the currentPhaseTotal is 2000, nextPhaseTotal is 1000, phaseThreshold is false, ignorePhaseThresholdWhenSkipped is false, and Sequence.js isn't animating", function() {
94 |
95 | var currentPhaseTotal = 2000,
96 | nextPhaseTotal = 1000,
97 | phaseThresholdOption = false,
98 | ignorePhaseThresholdWhenSkipped = false,
99 | isAnimating = false;
100 |
101 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
102 | next: 1000,
103 | current: 0
104 | }));
105 | });
106 |
107 |
108 | it("should return a current reversePhaseDelay of 1000 when the currentPhaseTotal is 1000, nextPhaseTotal is 2000, phaseThreshold is false, ignorePhaseThresholdWhenSkipped is false, and Sequence.js isn't animating", function() {
109 |
110 | var currentPhaseTotal = 1000,
111 | nextPhaseTotal = 2000,
112 | phaseThresholdOption = false,
113 | ignorePhaseThresholdWhenSkipped = false,
114 | isAnimating = false;
115 |
116 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
117 | next: 0,
118 | current: 1000
119 | }));
120 | });
121 |
122 |
123 | it("should return no reversePhaseDelay when the currentPhaseTotal and nextPhaseTotal are the same, phaseThreshold is false, ignorePhaseThresholdWhenSkipped is false, and Sequence.js isn't animating", function() {
124 |
125 | var currentPhaseTotal = 1000,
126 | nextPhaseTotal = 1000,
127 | phaseThresholdOption = false,
128 | ignorePhaseThresholdWhenSkipped = false,
129 | isAnimating = false;
130 |
131 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
132 | next: 0,
133 | current: 0
134 | }));
135 | });
136 |
137 |
138 | it("should not return a phaseThreshold when phaseThreshold is true", function() {
139 |
140 | var currentPhaseTotal = 2000,
141 | nextPhaseTotal = 1000,
142 | phaseThresholdOption = true,
143 | ignorePhaseThresholdWhenSkipped = false,
144 | isAnimating = false;
145 |
146 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
147 | next: 0,
148 | current: 0
149 | }));
150 | });
151 |
152 |
153 | it("should return a phaseThreshold when ignorePhaseThresholdWhenSkipped is false, regardless of whether Sequence is animating", function() {
154 |
155 | var currentPhaseTotal = 2000,
156 | nextPhaseTotal = 1000,
157 | phaseThresholdOption = false,
158 | ignorePhaseThresholdWhenSkipped = false,
159 | isAnimating = true;
160 |
161 | // When animating
162 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
163 | next: 1000,
164 | current: 0
165 | }));
166 |
167 | // When not animating
168 | isAnimating = false;
169 |
170 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
171 | next: 1000,
172 | current: 0
173 | }));
174 | });
175 |
176 |
177 | it("should not return a phaseThreshold when ignorePhaseThresholdWhenSkipped is true, and Sequence is animating", function() {
178 |
179 | var currentPhaseTotal = 2000,
180 | nextPhaseTotal = 1000,
181 | phaseThresholdOption = false,
182 | ignorePhaseThresholdWhenSkipped = true,
183 | isAnimating = true;
184 |
185 | expect(sequence.animation.getReversePhaseDelay(currentPhaseTotal, nextPhaseTotal, phaseThresholdOption, ignorePhaseThresholdWhenSkipped, isAnimating)).toEqual(jasmine.objectContaining({
186 | next: 0,
187 | current: 0
188 | }));
189 | });
190 | });
191 |
192 | describe("animation.getDirection()", function() {
193 |
194 | var sequence;
195 |
196 | // Set up Sequence and wait for it to be ready
197 | beforeAll(function(done) {
198 |
199 | appendSequence();
200 |
201 | sequence = initSequence();
202 |
203 | sequence.ready = function() {
204 | done();
205 | };
206 |
207 | });
208 |
209 | afterAll(function(done) {
210 | removeSequence();
211 | SetTimeout(function() {
212 | resetSequence(sequence);
213 | done();
214 | }, 500);
215 | });
216 |
217 | it("should return 1 when no direction is defined", function() {
218 |
219 | var id = 2,
220 | definedDirection = undefined,
221 | currentStepId = 1,
222 | noOfSteps = 3,
223 | isFallbackMode = false,
224 | reverseWhenNavigatingBackwardsOption = true,
225 | cycleOption = true;
226 |
227 | expect(sequence.animation.getDirection(id, definedDirection, currentStepId, noOfSteps, isFallbackMode, reverseWhenNavigatingBackwardsOption, cycleOption)).toEqual(1);
228 | });
229 |
230 |
231 | it("should return 1 when going from the last step to the first", function() {
232 |
233 | var id = 1,
234 | definedDirection = 1,
235 | currentStepId = 5,
236 | noOfSteps = 5,
237 | isFallbackMode = false,
238 | reverseWhenNavigatingBackwardsOption = true,
239 | cycleOption = true;
240 |
241 | expect(sequence.animation.getDirection(id, definedDirection, currentStepId, noOfSteps, isFallbackMode, reverseWhenNavigatingBackwardsOption, cycleOption)).toEqual(1);
242 | });
243 |
244 |
245 | it("should return 1 when the reverseWhenNavigatingBackwards option is disabled", function() {
246 |
247 | var id = 1,
248 | definedDirection = 1,
249 | currentStepId = 5,
250 | noOfSteps = 5,
251 | isFallbackMode = false,
252 | reverseWhenNavigatingBackwardsOption = false,
253 | cycleOption = true;
254 |
255 | expect(sequence.animation.getDirection(id, definedDirection, currentStepId, noOfSteps, isFallbackMode, reverseWhenNavigatingBackwardsOption, cycleOption)).toEqual(1);
256 | });
257 |
258 |
259 | it("should return 1 when in fallback mode", function() {
260 |
261 | var id = 1,
262 | definedDirection = 1,
263 | currentStepId = 5,
264 | noOfSteps = 5,
265 | isFallbackMode = true,
266 | reverseWhenNavigatingBackwardsOption = true,
267 | cycleOption = true;
268 |
269 | expect(sequence.animation.getDirection(id, definedDirection, currentStepId, noOfSteps, isFallbackMode, reverseWhenNavigatingBackwardsOption, cycleOption)).toEqual(1);
270 | });
271 |
272 | it("should return 1 when the step being navigated to is ahead of the current step", function() {
273 |
274 | var id = 2,
275 | definedDirection = undefined,
276 | currentStepId = 1,
277 | noOfSteps = 5,
278 | isFallbackMode = false,
279 | reverseWhenNavigatingBackwardsOption = true,
280 | cycleOption = true;
281 |
282 | expect(sequence.animation.getDirection(id, definedDirection, currentStepId, noOfSteps, isFallbackMode, reverseWhenNavigatingBackwardsOption, cycleOption)).toEqual(1);
283 | });
284 |
285 |
286 | it("should return -1 when the step being navigated to is before the current step", function() {
287 |
288 | var id = 2,
289 | definedDirection = undefined,
290 | currentStepId = 3,
291 | noOfSteps = 5,
292 | isFallbackMode = false,
293 | reverseWhenNavigatingBackwardsOption = true,
294 | cycleOption = true;
295 |
296 | expect(sequence.animation.getDirection(id, definedDirection, currentStepId, noOfSteps, isFallbackMode, reverseWhenNavigatingBackwardsOption, cycleOption)).toEqual(-1);
297 | });
298 | });
299 |
--------------------------------------------------------------------------------
/tests/spec/autoplay.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.autoPlay
3 | */
4 | describe("autoPlay", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence({
14 | autoPlay: false
15 | });
16 |
17 | sequence.ready = function() {
18 | done();
19 | };
20 | });
21 |
22 | afterAll(function(done) {
23 | removeSequence();
24 | SetTimeout(function() {
25 | resetSequence(sequence);
26 | done();
27 | }, 500);
28 | });
29 |
30 | it("should allow autoPlay to be started once, then prevent autoPlay from being started again when already active", function() {
31 |
32 | // Start once then try starting again
33 | expect(sequence.autoPlay.start()).toEqual(true);
34 | expect(sequence.autoPlay.start()).toEqual(false);
35 | });
36 | });
37 |
38 | describe("autoPlay.getDelay()", function() {
39 |
40 | var sequence;
41 |
42 | // Set up Sequence and wait for it to be ready
43 | beforeAll(function(done) {
44 |
45 | appendSequence();
46 |
47 | sequence = initSequence({
48 | autoPlay: false
49 | });
50 |
51 | sequence.ready = function() {
52 | done();
53 | };
54 | });
55 |
56 | afterAll(function(done) {
57 | removeSequence();
58 | SetTimeout(function() {
59 | resetSequence(sequence);
60 | done();
61 | }, 500);
62 | });
63 |
64 | it("should return a delay with the same value as options.autoPlayInterval when delay is true or options.autoPlayDelay is null", function() {
65 |
66 | expect(sequence.autoPlay.getDelay(true, null, 5000)).toEqual(5000);
67 | });
68 |
69 | it("should return a delay with the same value as options.autoPlayDelay when delay is true or undefined", function() {
70 |
71 | expect(sequence.autoPlay.getDelay(true, 250, 5000)).toEqual(250);
72 | });
73 |
74 | it("should return a delay of 0 when delay is false or undefined", function() {
75 |
76 | expect(sequence.autoPlay.getDelay(false, null, 5000)).toEqual(0);
77 | expect(sequence.autoPlay.getDelay(undefined, 250, 5000)).toEqual(0);
78 | expect(sequence.autoPlay.getDelay(undefined, null, 5000)).toEqual(0);
79 | });
80 |
81 | it("should return a delay of 750 when a custom delay is defined, regardless of options.autoPlayInterval and options.autoPlayDelay", function() {
82 |
83 | expect(sequence.autoPlay.getDelay(750, null, 5000)).toEqual(750);
84 | expect(sequence.autoPlay.getDelay(750, 250, 5000)).toEqual(750);
85 | });
86 | });
87 |
88 | describe("autoPlay.stop()", function() {
89 | var sequence;
90 |
91 | // Set up Sequence and wait for it to be ready
92 | beforeAll(function(done) {
93 |
94 | appendSequence();
95 |
96 | sequence = initSequence({
97 | autoPlay: false
98 | });
99 |
100 | sequence.ready = function() {
101 | done();
102 | };
103 | });
104 |
105 | afterAll(function(done) {
106 | removeSequence();
107 | SetTimeout(function() {
108 | resetSequence(sequence);
109 | done();
110 | }, 500);
111 | });
112 |
113 | it("should stop autoPlay if the autoPlay option is enabled and active", function() {
114 |
115 | sequence.options.autoPlay = true;
116 | sequence.isAutoPlaying = true;
117 |
118 | expect(sequence.autoPlay.stop()).toEqual(true);
119 | });
120 |
121 | it("should not stop autoPlay if it doesn't need to (because the autoPlay option is disabled)", function() {
122 |
123 | sequence.options.autoPlay = false;
124 |
125 | expect(sequence.autoPlay.stop()).toEqual(false);
126 | });
127 |
128 | it("should not stop autoPlay if it doesn't need to (because autoPlay isn't active anyway)", function() {
129 |
130 | sequence.isAutoPlaying = false;
131 |
132 | expect(sequence.autoPlay.stop()).toEqual(false);
133 | });
134 | });
135 |
136 |
137 | describe("autoPlay.unpause() / autoPlay.pause()", function() {
138 | var sequence;
139 |
140 | // Set up Sequence and wait for it to be ready
141 | beforeAll(function(done) {
142 |
143 | appendSequence();
144 |
145 | sequence = initSequence({
146 | autoPlay: false
147 | });
148 |
149 | sequence.ready = function() {
150 | done();
151 | };
152 | });
153 |
154 | afterAll(function(done) {
155 | removeSequence();
156 | SetTimeout(function() {
157 | resetSequence(sequence);
158 | done();
159 | }, 500);
160 | });
161 |
162 | it("should unpause autoPlay if autoPlay was previously paused", function() {
163 |
164 | expect(sequence.autoPlay.unpause()).toEqual(false);
165 |
166 | sequence.isAutoPlayPaused = true;
167 | expect(sequence.autoPlay.unpause()).toEqual(true);
168 | });
169 |
170 | it("should pause autoPlay if autoPlay was previously unpaused", function() {
171 |
172 | expect(sequence.autoPlay.pause()).toEqual(true);
173 |
174 | sequence.isAutoPlayPaused = true;
175 | expect(sequence.autoPlay.pause()).toEqual(false);
176 | });
177 | });
178 |
--------------------------------------------------------------------------------
/tests/spec/canvas.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.canvas
3 | */
4 | describe("canvas move()", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence({
14 | animateCanvas: true
15 | });
16 |
17 | sequence.ready = function() {
18 | done();
19 | };
20 |
21 | });
22 |
23 | afterAll(function(done) {
24 | removeSequence();
25 | SetTimeout(function() {
26 | resetSequence(sequence);
27 | done();
28 | }, 500);
29 | });
30 |
31 | it("should return false when the animateCanvas option is disabled and true when the canvas was successfully moved", function() {
32 |
33 | sequence.options.animateCanvas = false;
34 | expect(sequence.canvas.move(1, true)).toEqual(false);
35 |
36 | sequence.options.animateCanvas = true;
37 | expect(sequence.canvas.move(1, true)).toEqual(true);
38 | });
39 |
40 | });
41 |
42 | describe("canvas removeNoJsClass()", function() {
43 |
44 | var sequence;
45 |
46 | // Set up Sequence and wait for it to be ready
47 | beforeAll(function(done) {
48 |
49 | appendSequence();
50 |
51 | sequence = initSequence();
52 |
53 | sequence.ready = function() {
54 | done();
55 | };
56 |
57 | });
58 |
59 | afterAll(function(done) {
60 | removeSequence();
61 | SetTimeout(function() {
62 | resetSequence(sequence);
63 | done();
64 | }, 500);
65 | });
66 |
67 | it("removeNoJsClass() should remove the No-JS class from any step that was given it", function() {
68 |
69 | var step2 = document.getElementById("step2");
70 | expect(step2.classList.length).toEqual(0);
71 | });
72 |
73 | });
74 |
--------------------------------------------------------------------------------
/tests/spec/events.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.manageEvents
3 | */
4 | describe("manageEvents()", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence();
14 |
15 | sequence.ready = function() {
16 | done();
17 | };
18 | });
19 |
20 | afterAll(function(done) {
21 | removeSequence();
22 | SetTimeout(function() {
23 | resetSequence(sequence);
24 | done();
25 | }, 500);
26 | });
27 |
28 | it("should add a hashChange event and return the element and handler function", function(done) {
29 |
30 | var myEvent = sequence.manageEvents.add.hashChange()[0];
31 | expect(myEvent.element).not.toEqual(undefined);
32 | expect(typeof myEvent.handler === "function").toEqual(true);
33 | done();
34 | });
35 |
36 | it("should add a button event and return the element and handler function", function(done) {
37 |
38 | // Use a nextButton, and add it with an empty function
39 | var button = sequence.ui.getElements("nextButton", true);
40 | var myEvent = sequence.manageEvents.add.button(button, "nav", function(){})[0];
41 |
42 | expect(myEvent.element).not.toEqual(undefined);
43 | expect(typeof myEvent.handler === "function").toEqual(true);
44 | done();
45 | });
46 | });
47 |
--------------------------------------------------------------------------------
/tests/spec/goto.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.goTo()
3 | */
4 | describe("goTo()", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence({
14 | autoPlay: false
15 | });
16 |
17 | sequence.ready = function() {
18 | done();
19 | };
20 | });
21 |
22 | afterAll(function(done) {
23 | removeSequence();
24 | SetTimeout(function() {
25 | resetSequence(sequence);
26 | done();
27 | }, 500);
28 | });
29 |
30 | it("should prevent going to the same step already being viewed", function() {
31 |
32 | setTimeout(function() {
33 | sequence.goTo(1);
34 | expect(sequence.goTo(1)).toEqual(false);
35 | }, 100);
36 |
37 | });
38 |
39 | it("should prevent going to a non-existent step", function() {
40 |
41 | expect(sequence.goTo(5)).toEqual(false);
42 | expect(sequence.goTo(-1)).toEqual(false);
43 | });
44 |
45 | it("should prevent going to a step whilst another is animating and navigationSkip is disabled", function() {
46 |
47 | sequence.options.navigationSkip = false;
48 | sequence.isAnimating = true;
49 |
50 | expect(sequence.goTo(2)).toEqual(false);
51 | });
52 |
53 | it("should prevent going to a step if the navigationSkipThreshold is active", function() {
54 |
55 | sequence.options.navigationSkip = true;
56 | sequence.navigationSkipThresholdActive = true;
57 |
58 | expect(sequence.goTo(2)).toEqual(false);
59 | });
60 | });
61 |
--------------------------------------------------------------------------------
/tests/spec/hashtags.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.hashtags
3 | */
4 | describe("hashtags.getStepHashTags()", function() {
5 |
6 |
7 | var sequence;
8 |
9 | // Set up Sequence and wait for it to be ready
10 | beforeAll(function(done) {
11 |
12 | appendSequence();
13 |
14 | setTimeout(function() {
15 | sequence = initSequence({
16 | autoPlay: false,
17 | hashTags: true,
18 | startingStepId: 2
19 | });
20 |
21 | sequence.ready = function() {
22 | done();
23 | };
24 | }, 1000);
25 | });
26 |
27 | afterAll(function(done) {
28 | removeSequence();
29 | SetTimeout(function() {
30 | resetSequence(sequence);
31 | done();
32 | }, 500);
33 | });
34 |
35 | it("should return an array containing a hashtag name for each step, taken from the step's ID attribute", function() {
36 |
37 | expect(sequence.hashTags.getStepHashTags()).toEqual(jasmine.any(Array));
38 | expect(sequence.hashTags.getStepHashTags()[0]).toEqual("step1");
39 | });
40 |
41 | it("should return an array containing a hashtag name for each step, taken from the step's data-seq-hashtag attribute", function() {
42 |
43 | sequence.options.hashDataAttribute = true;
44 |
45 | expect(sequence.hashTags.getStepHashTags()).toEqual(jasmine.any(Array));
46 | expect(sequence.hashTags.getStepHashTags()[0]).toEqual("step1attr");
47 | });
48 | });
49 |
50 |
51 | describe("hashtags.hasCorrespondingStep()", function() {
52 |
53 |
54 | var sequence;
55 |
56 | // Set up Sequence and wait for it to be ready
57 | beforeAll(function(done) {
58 |
59 | appendSequence();
60 |
61 | setTimeout(function() {
62 | sequence = initSequence({
63 | autoPlay: false,
64 | hashTags: true,
65 | startingStepId: 2
66 | });
67 |
68 | sequence.ready = function() {
69 | done();
70 | };
71 | }, 1000);
72 | });
73 |
74 | afterAll(function(done) {
75 | removeSequence();
76 | SetTimeout(function() {
77 | resetSequence(sequence);
78 | done();
79 | }, 500);
80 | });
81 |
82 | it("should return the zero-based ID of the step that the hashtag corresponds to", function() {
83 |
84 | // The hashtag "step1" should match an element with the ID of step1
85 | expect(sequence.hashTags.hasCorrespondingStep("step1")).toEqual(0);
86 | });
87 |
88 | it("should return -1 when the hashtag tested doesn't have a corresponding step", function() {
89 |
90 | expect(sequence.hashTags.hasCorrespondingStep("step4")).toEqual(-1);
91 | });
92 | });
93 |
--------------------------------------------------------------------------------
/tests/spec/init.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Test initiation of Sequence
3 | */
4 | describe("Sequence initiation", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence({
14 | autoPlay: true
15 | });
16 |
17 | sequence.ready = function() {
18 | done();
19 | };
20 | });
21 |
22 | afterAll(function(done) {
23 | removeSequence();
24 | SetTimeout(function() {
25 | resetSequence(sequence);
26 | done();
27 | }, 500);
28 | });
29 |
30 | it("should return the sequence object", function() {
31 |
32 | expect(sequence).toEqual(jasmine.any(Object));
33 | });
34 |
35 | it("should add data-seq-enabled to the element", function() {
36 | expect(parseInt(sequence.$container.dataset.seqEnabled)).toEqual(jasmine.any(Number));
37 | });
38 |
39 | it("should merge and override default options with developer options (change autoPlay from the default of false to true)", function() {
40 |
41 | expect(sequence.options.autoPlay).toEqual(true);
42 | });
43 |
44 | it("should expose properties", function() {
45 |
46 | expect(sequence.options).toEqual(jasmine.any(Object));
47 | expect(sequence.$container.id).toEqual("sequence");
48 | expect(sequence.$screen.classList.contains("seq-screen")).toEqual(true);
49 | expect(sequence.$canvas.classList.contains("seq-canvas")).toEqual(true);
50 | expect(sequence.$steps).toEqual(jasmine.any(Array));
51 |
52 | expect(sequence.isAnimating).not.toEqual(undefined);
53 | expect(sequence.isReady).not.toEqual(undefined);
54 | expect(sequence.noOfSteps).not.toEqual(undefined);
55 | expect(sequence.stepProperties).not.toEqual(undefined);
56 | expect(sequence.propertySupport).not.toEqual(undefined);
57 | expect(sequence.isFallbackMode).not.toEqual(undefined);
58 | expect(sequence.firstRun).not.toEqual(undefined);
59 | expect(sequence.currentStepId).not.toEqual(undefined);
60 | expect(sequence.isReady).not.toEqual(undefined);
61 | });
62 | });
63 |
64 | describe("Sequence multiple instantiations", function() {
65 |
66 | var sequence;
67 |
68 | // Set up Sequence and wait for it to be ready
69 | beforeAll(function(done) {
70 |
71 | appendSequence();
72 |
73 | // Init Sequence on
74 | sequence = initSequence();
75 |
76 | sequence.ready = function() {
77 | done();
78 | };
79 | });
80 |
81 | afterAll(function(done) {
82 | removeSequence();
83 | SetTimeout(function() {
84 | resetSequence(sequence);
85 | done();
86 | }, 500);
87 | });
88 |
89 | it("should prevent a second instantiation on the same element and instead return the object already attached to the element", function() {
90 |
91 | // Get the instanceId added the first time on the element
92 | var originalInstanceId = parseInt(sequence.$container.dataset.seqEnabled);
93 | expect(originalInstanceId).toEqual(jasmine.any(Number));
94 |
95 | // Init Sequence AGAIN on
96 | sequence = initSequence({}, "sequence");
97 |
98 | // Make sure the same instanceId is returned
99 | expect(parseInt(sequence.$container.dataset.seqEnabled)).toEqual(originalInstanceId);
100 | });
101 | });
102 |
--------------------------------------------------------------------------------
/tests/spec/methods.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Tests for small methods
3 | */
4 | describe("next()", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence({
14 | autoPlay: false,
15 | cycle: true
16 | });
17 |
18 | sequence.ready = function() {
19 | done();
20 | };
21 | });
22 |
23 | afterAll(function(done) {
24 | removeSequence();
25 | SetTimeout(function() {
26 | resetSequence(sequence);
27 | done();
28 | }, 500);
29 | });
30 |
31 | it("should go to the next step and return the ID of that step", function() {
32 |
33 | sequence.currentStepId = 1;
34 | expect(sequence.next()).toEqual(2);
35 | });
36 |
37 | it("should go to the first step if the current step is the last and the cycle option is enabled", function() {
38 |
39 | sequence.currentStepId = 3;
40 | expect(sequence.next()).toEqual(1);
41 | });
42 |
43 | it("should prevent next() if on the last step and the cycle option is disabled", function() {
44 |
45 | sequence.options.cycle = false;
46 | sequence.currentStepId = 3;
47 | expect(sequence.next()).toEqual(false);
48 | });
49 | });
50 |
51 | describe("prev()", function() {
52 |
53 | var sequence;
54 |
55 | // Set up Sequence and wait for it to be ready
56 | beforeAll(function(done) {
57 |
58 | appendSequence();
59 |
60 | sequence = initSequence({
61 | autoPlay: false,
62 | cycle: true,
63 | startingStepId: 3
64 | });
65 |
66 | sequence.ready = function() {
67 | done();
68 | };
69 | });
70 |
71 | afterAll(function(done) {
72 | removeSequence();
73 | SetTimeout(function() {
74 | resetSequence(sequence);
75 | done();
76 | }, 500);
77 | });
78 |
79 | it("should go to the previous step and return the ID of that step", function() {
80 |
81 | sequence.currentStepId = 2;
82 | expect(sequence.prev()).toEqual(1);
83 | });
84 |
85 | it("should go to the last step if the current step is the first and the cycle option is enabled", function() {
86 |
87 | sequence.currentStepId = 1;
88 | expect(sequence.prev()).toEqual(3);
89 | });
90 |
91 | it("should prevent prev() if on the first step and the cycle option is disabled", function() {
92 |
93 | sequence.options.cycle = false;
94 | sequence.currentStepId = 1;
95 | expect(sequence.prev()).toEqual(false);
96 | });
97 | });
98 |
99 | describe("toggleAutoPlay()", function() {
100 |
101 | var sequence;
102 |
103 | // Set up Sequence and wait for it to be ready
104 | beforeAll(function(done) {
105 |
106 | appendSequence();
107 |
108 | sequence = initSequence({
109 | autoPlay: true
110 | });
111 |
112 | sequence.ready = function() {
113 | done();
114 | };
115 | });
116 |
117 | it("should stop auoPlay and return false if autoPlay was active", function() {
118 |
119 | sequence.isAutoPlaying = true;
120 | expect(sequence.toggleAutoPlay()).toEqual(false);
121 | });
122 |
123 | it("should start auoPlay and return true if autoPlay was inactive", function() {
124 |
125 | sequence.stop();
126 | expect(sequence.toggleAutoPlay()).toEqual(true);
127 | });
128 |
129 | });
130 |
--------------------------------------------------------------------------------
/tests/spec/pagination.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.pagination
3 | */
4 | describe("pagination", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence();
14 |
15 | sequence.ready = function() {
16 | done();
17 | };
18 | });
19 |
20 | afterAll(function(done) {
21 | removeSequence();
22 | SetTimeout(function() {
23 | resetSequence(sequence);
24 | done();
25 | }, 500);
26 | });
27 |
28 | it("getLinks() should return an array containing 3 pagination links", function() {
29 |
30 | var $pagination = document.querySelectorAll(".seq-pagination")[0],
31 | paginationLinks = sequence.pagination.getLinks($pagination, "sequence");
32 |
33 | expect(paginationLinks).toEqual(jasmine.any(Array));
34 | expect(paginationLinks.length).toEqual(3);
35 | });
36 |
37 | it("update() should return the current pagination link", function() {
38 |
39 | var currentPaginationLink = sequence.pagination.update();
40 |
41 | expect(currentPaginationLink).toEqual(jasmine.any(Array));
42 | expect(currentPaginationLink.length).toEqual(1);
43 | });
44 |
45 | });
46 |
--------------------------------------------------------------------------------
/tests/spec/preloader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.preloader
3 | */
4 | describe("preloader", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence();
14 |
15 | sequence.ready = function() {
16 | done();
17 | };
18 | });
19 |
20 | afterAll(function(done) {
21 | removeSequence();
22 | SetTimeout(function() {
23 | resetSequence(sequence);
24 | done();
25 | }, 500);
26 | });
27 |
28 | it("init() should return true when the default preloader is used", function() {
29 |
30 | sequence.options.preloader = true;
31 | expect(sequence.preload.init()).toEqual(true);
32 | });
33 |
34 | it("init() should return true when a custom preloader element is used", function() {
35 |
36 | sequence.options.preloader = ".seq-custom-preload-element";
37 | expect(sequence.preload.init()).toEqual(true);
38 | });
39 |
40 | it("init() should return false when the preloader isn't used", function() {
41 |
42 | sequence.options.preloader = false;
43 | expect(sequence.preload.init()).toEqual(false);
44 | });
45 |
46 | it("should add the default preloader element to the document", function() {
47 |
48 | sequence.options.preloader = true;
49 | var defaultPreloader = document.querySelectorAll(".seq-preloader");
50 |
51 | expect(defaultPreloader.length).toBeGreaterThan(0);
52 | });
53 |
54 | it("should return false when the default preloader is not being used", function() {
55 |
56 | sequence.options.preloader = false;
57 | expect(sequence.preload.append()).toEqual(false);
58 |
59 | sequence.options.preloader = '#custom-preloader';
60 | expect(sequence.preload.append()).toEqual(false);
61 | });
62 |
63 | it("should return true when the default preloader is being used", function() {
64 |
65 | sequence.options.preloader = true;
66 | expect(sequence.preload.append()).toEqual(true);
67 | });
68 |
69 | it("hideStepsUntilPreloaded() should return true when enabled", function() {
70 |
71 | sequence.options.hideStepsUntilPreloaded = true;
72 | expect(sequence.preload.toggleStepsVisibility()).toEqual(true);
73 | });
74 |
75 | it("hideStepsUntilPreloaded() should return false when disabled", function() {
76 |
77 | sequence.options.hideStepsUntilPreloaded = false;
78 | expect(sequence.preload.toggleStepsVisibility()).toEqual(false);
79 | });
80 |
81 | it("getImagesToPreload() should return an empty array if the images or src attributes aren't specificed in an array", function() {
82 |
83 | var imagesToPreload = "images/hi.jpg";
84 | expect(sequence.preload.getImagesToPreload(imagesToPreload)).toEqual(jasmine.any(Array));
85 | });
86 | });
87 |
--------------------------------------------------------------------------------
/tests/spec/ui.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sequence.ui
3 | */
4 | describe("ui.getElements()", function() {
5 |
6 | var sequence;
7 |
8 | // Set up Sequence and wait for it to be ready
9 | beforeAll(function(done) {
10 |
11 | appendSequence();
12 |
13 | sequence = initSequence();
14 |
15 | sequence.ready = function() {
16 | done();
17 | };
18 | });
19 |
20 | afterAll(function(done) {
21 | removeSequence();
22 | SetTimeout(function() {
23 | resetSequence(sequence);
24 | done();
25 | }, 500);
26 | });
27 |
28 | it("should get a default element (.seq-next)", function() {
29 |
30 | var nextButton = sequence.ui.getElements("nextButton", true);
31 | var expectedNextButton = document.querySelectorAll(".seq-next");
32 |
33 | expect(nextButton).toEqual([expectedNextButton[0]]);
34 |
35 | done();
36 | });
37 |
38 | it("should get a custom element via a CSS Selector (.custom-next)", function() {
39 |
40 | var nextButton = sequence.ui.getElements("nextButton", ".custom-next");
41 | var expectedNextButton = document.querySelectorAll(".custom-next");
42 |
43 | expect(nextButton).toEqual([expectedNextButton[0]]);
44 |
45 | done();
46 | });
47 |
48 | it("should get a custom element via an ID Selector (#next)", function() {
49 |
50 | var nextButton = sequence.ui.getElements("nextButton", "#next");
51 | var expectedNextButton = document.querySelectorAll("#next");
52 |
53 | expect(nextButton).toEqual([expectedNextButton[0]]);
54 | });
55 | });
56 |
--------------------------------------------------------------------------------
/tests/themes/amd/README.md:
--------------------------------------------------------------------------------
1 | # Test Theme
2 |
3 | > Used for Testing Sequence
4 |
5 | Test Theme is powered by [Sequence.js](http://sequencejs.com/) - The open-source CSS animation framework.
6 |
7 | Author: [Ian Lunn](https://ianlunn.co.uk/)
8 | Email: [hello@ianlunn.co.uk](mailto://hello@ianlunn.co.uk)
9 | GitHub: [@IanLunn](https://github.com/IanLunn)
10 | Twitter: [@IanLunn](https://twitter.com/IanLunn)
11 |
12 | License: [MIT](http://opensource.org/licenses/MIT)
13 |
14 | Copyright (c) 2014 Ian Lunn
15 |
16 | ## Getting Started
17 |
18 | 1. Move the `test-theme` directory to the same directory as the page you'd like the theme to appear on.
19 | 2. Add the stylesheet within the `` tags on your page below existing stylesheets, using the following:
20 | ``
21 | 3. From index.html in the downloaded theme, copy everything inside the tags, then paste into the page you'd like the theme to appear on.
22 | 4. Add a reference to the Sequence library, its third-party dependencies, and the theme options just before the closing `
11 |
12 |
13 |
14 |
15 |
16 |
Box 1
17 |
Box 1b
18 |
19 |
20 |
Box 2
21 |
Box 2b
22 |
23 |
24 |
Box 3
25 |
Box 3b
26 |
27 |
28 |
29 |
30 |
31 |
32 |
` element on your page:
23 | ```javascript
24 |
25 |
26 |
27 |
28 | ```
29 | 5. From index.html in the downloaded theme, copy everything inside the
tags, then paste into the page you'd like the theme to appear on.
30 | 6. Save your file and upload newly added/modified files to your web server. You're done!
31 |
32 | A theme's options can be changed in `scripts/sequence-theme.test-theme.js`. See Options in the [documentation](http://www.sequencejs.com/developers/documentation/).
33 |
34 | ## Support
35 |
36 | For theme support, please use the following contact details:
37 |
38 | Email: [info@sequencejs.com](mailto://info@sequencejs.com)
39 | Website: [http://sequencejs.com/](http://sequencejs.com/)
40 |
41 | ## Sequence.js License
42 |
43 | The [Sequence.js](http://sequencejs.com/) library is made available under the following open-source [MIT license](http://opensource.org/licenses/MIT):
44 |
45 | > Copyright (c) 2014 Ian Lunn Design Limited
46 |
47 | > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
48 |
49 | > THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 |
51 | Sequence themes are made available under their own licenses. Please respect them accordingly.
52 |
53 | ## Release History
54 | *Nothing yet*
--------------------------------------------------------------------------------
/tests/themes/amd/css/sequence-theme.test-theme.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Theme Name: Test Theme
3 | * Version: 0.1.0
4 | * Theme URL:
5 | *
6 | * Used for Testing Sequence
7 | *
8 | * Powered by Sequence.js - The open-source CSS animation framework.
9 | *
10 | * Author: Ian Lunn
11 | * Author URL: https://ianlunn.co.uk/
12 | *
13 | * Test Theme Sequence Theme Copyright (c) Ian Lunn 2014
14 | * License: MIT http://opensource.org/licenses/MIT
15 | *
16 | * Sequence.js and its dependencies are copyright (c) Ian Lunn 2014 unless otherwise stated.
17 | */
18 |
19 | .seq-current {
20 | border: red solid 1px;
21 | }
22 |
23 | #sequence {
24 | position: relative;
25 | height: 300px;
26 | width: 100%;
27 | max-width: 500px;
28 | margin: 0 auto;
29 | padding: 0;
30 | border: black solid 2px;
31 | font-family: sans-serif;
32 | }
33 |
34 | #sequence.seq-fallback {
35 | border: blue solid 2px;
36 | }
37 |
38 | #sequence .seq-screen,
39 | #sequence .seq-canvas,
40 | #sequence .seq-canvas > * {
41 | position: absolute;
42 | height: 100%;
43 | width: 100%;
44 | margin: 0;
45 | padding: 0;
46 | list-style: none;
47 | }
48 |
49 | #sequence .box {
50 | position: absolute;
51 | height: 100px;
52 | width: 100px;
53 | border: red solid 1px;
54 | left: 100%;
55 | -webkit-transition-duration: 4s;
56 | transition-duration: 4s;
57 | /*transition-timing-function: linear;*/
58 | }
59 |
60 | #sequence #step3 .box {
61 | /*transition-delay: 1s;*/
62 | }
63 |
64 | #sequence #step3 .boxb {
65 | -webkit-transition-duration: 3s;
66 | transition-duration: 3s;
67 | /*transition-delay: 1s;*/
68 | }
69 |
70 | #sequence .boxb {
71 | top: 200px;
72 | }
73 |
74 | #sequence .seq-in .box {
75 | left: 50%;
76 | margin-left: -50px;
77 | }
78 |
79 | #sequence .seq-out .box {
80 | left: 0;
81 | margin-left: -100px;
82 | }
83 |
--------------------------------------------------------------------------------
/tests/themes/amd/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |