diff options
author | Saivan <savian@me.com> | 2018-04-18 20:55:06 +1000 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-04-18 20:55:06 +1000 |
commit | 7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c (patch) | |
tree | 55c8efb1dd5954544dc14702424388f26f31e1e1 /spec | |
parent | c37d94a4dccd3c0d2ce8db99bd80b6e514f5c7de (diff) | |
download | svg.js-7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c.tar.gz svg.js-7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c.zip |
Initial planning for the Timeline Module
This commit just includes a few plans and a massive derrangement
of the fx module before it is to be refactored into the Timeline
module. The basic methods are included, but everything is broken
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/circle.js | 2 | ||||
-rw-r--r-- | spec/spec/queue.js | 111 |
2 files changed, 112 insertions, 1 deletions
diff --git a/spec/spec/circle.js b/spec/spec/circle.js index c0f0936..0f2c8f4 100644 --- a/spec/spec/circle.js +++ b/spec/spec/circle.js @@ -1,3 +1,4 @@ + describe('Circle', function() { var circle @@ -173,5 +174,4 @@ describe('Circle', function() { expect(window.matrixStringToArray(circle.node.getAttribute('transform'))).toEqual([1,0,0,1,12,12]) }) }) - }) diff --git a/spec/spec/queue.js b/spec/spec/queue.js new file mode 100644 index 0000000..738831c --- /dev/null +++ b/spec/spec/queue.js @@ -0,0 +1,111 @@ + +describe ('SVG.Queue()', function () { + + describe('first ()', function () { + + it('returns null if no item in the queue', function () { + var queue = new SVG.Queue() + expect(queue.first()).toEqual(null) + }) + + it ('returns the first value in the queue', function () { + var queue = new SVG.Queue() + queue.push(1) + expect(queue.first()).toBe(1) + queue.push(2) + expect(queue.first()).toBe(1) + }) + }) + + describe('last ()', function () { + + it ('returns null if no item in the queue', function () { + var queue = new SVG.Queue() + expect(queue.last()).toEqual(null) + }) + + it ('returns the last value added', function () { + var queue = new SVG.Queue() + queue.push(1) + expect(queue.last()).toBe(1) + queue.push(2) + expect(queue.last()).toBe(2) + }) + }) + + describe('push ()', function () { + + it ('adds an element to the end of the queue', function () { + var queue = new SVG.Queue() + queue.push(1) + queue.push(2) + queue.push(3) + + expect(queue.first()).toBe(1) + expect(queue.last()).toBe(3) + }) + + it ('changes the length when you add things', function () { + var queue = new SVG.Queue() + queue.push(1) + expect(queue.length).toBe(1) + queue.push(2) + expect(queue.length).toBe(2) + }) + }) + + describe('remove ()', function () { + it('removes an item from the queue which matches the matcher', function () { + var queue = new SVG.Queue() + queue.push(1) + queue.push(2) + queue.push(3) + + queue.remove(function(item) { + return item.value == 3 + }) + + expect(queue.length).toBe(2) + expect(queue.last()).toBe(2) + expect(queue.first()).toBe(1) + }) + + it('removes no item from the queue if nothing is matched', function () { + var queue = new SVG.Queue() + queue.push(1) + queue.push(2) + queue.push(3) + + queue.remove(function(item) { + return item.value == 4 + }) + + expect(queue.length).toBe(3) + expect(queue.last()).toBe(3) + expect(queue.first()).toBe(1) + }) + }) + + describe('shift ()', function () { + it('returns nothing if queue is empty', function () { + var queue = new SVG.Queue() + var val = queue.shift() + expect(val).toBeFalsy() + }) + + it('returns the first item of the queue and removes it', function () { + var queue = new SVG.Queue() + queue.push(1) + queue.push(2) + queue.push(3) + + var val = queue.shift() + + expect(queue.length).toBe(2) + expect(queue.last()).toBe(3) + expect(queue.first()).toBe(2) + + expect(val).toBe(1) + }) + }) +}) |