diff options
author | wout <wout@impinc.co.uk> | 2013-07-02 14:36:09 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-07-02 14:36:09 +0100 |
commit | c30c718d904dc35bd99595ab37d5bb8cac796570 (patch) | |
tree | 58774563c7cc8393e21774fae98dc730115efca2 /spec/spec/memory.js | |
parent | f492d5d57790e4f3606a3370b1e676a38a9fd7a9 (diff) | |
download | svg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.tar.gz svg.js-c30c718d904dc35bd99595ab37d5bb8cac796570.zip |
Added memory module
Diffstat (limited to 'spec/spec/memory.js')
-rw-r--r-- | spec/spec/memory.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/spec/memory.js b/spec/spec/memory.js new file mode 100644 index 0000000..b3a60e0 --- /dev/null +++ b/spec/spec/memory.js @@ -0,0 +1,52 @@ +describe('Memory', function () { + var rect + + beforeEach(function() { + rect = draw.rect(100,120) + }) + + afterEach(function() { + draw.clear() + }) + + describe('remember()', function() { + it('accepts an object with values', function() { + rect.remember({ bbox: rect.bbox() }) + rect.size(200,300) + expect(rect.remember('bbox').width).toBe(100) + }) + it('accepts key / value arguments', function() { + rect.remember('fill', rect.attr('fill')) + rect.fill('#f09') + expect(rect.remember('fill')).toBe('#000000') + }) + it('acts as a getter with one string argument', function() { + rect.remember('opacity', 0.85) + expect(rect.remember('opacity')).toBe(0.85) + }) + }) + + describe('forget()', function() { + it('deletes a given memory', function() { + rect.remember({ grass: 'is green', one: 1 }) + rect.forget('grass') + expect(rect.remember('grass')).toBe(undefined) + expect(rect.remember('one')).toBe(1) + }) + it('accepts multiple arguments as different memories', function() { + rect.remember({ grass: 'might be purple', two: 2, sea: true }) + rect.forget('grass', 'sea') + expect(rect.remember('grass')).toBe(undefined) + expect(rect.remember('sea')).toBe(undefined) + expect(rect.remember('two')).toBe(2) + }) + it('clears the whole memory without arguments', function() { + rect.remember({ grass: 'is never pink', three: 3, tree: true }) + rect.forget() + expect(rect.remember('grass')).toBe(undefined) + expect(rect.remember('tree')).toBe(undefined) + expect(rect.remember('three')).toBe(undefined) + }) + }) + +})
\ No newline at end of file |