|
1 | 1 | 'use strict' |
| 2 | +describe 'CommentSpaceAllocators', -> |
| 3 | + scrollCSA = anchorCSA = manager = stage = c1 = c2 = s1 = s2 = null |
2 | 4 |
|
3 | | -describe 'AnchorCommentSpaceAllocator', -> |
4 | | - xit('TODO: add some examples to (or delete) it') |
| 5 | + describe 'instance ISpaceAllocator and descendants', -> |
| 6 | + beforeEach -> |
| 7 | + scrollCSA = new CommentSpaceAllocator(400,300) |
| 8 | + anchorCSA = new AnchorCommentSpaceAllocator(400,300) |
| 9 | + stage = document.createElement 'DIV' |
| 10 | + manager = new CommentManager(stage) |
| 11 | + manager.init() |
| 12 | + c1 = new CoreComment(manager, {}) |
| 13 | + c2 = new CoreComment(manager, {}) |
| 14 | + s1 = new ScrollComment(manager, {}) |
| 15 | + s2 = new ScrollComment(manager, {}) |
| 16 | + c1.init(); |
| 17 | + c2.init(); |
| 18 | + s1.init(); |
| 19 | + s2.init(); |
5 | 20 |
|
6 | | -describe 'CommentSpaceAllocator', -> |
7 | | - xit('TODO: add some examples to (or delete) it') |
| 21 | + 'add remove setBounds'.split(' ').forEach (method)-> |
| 22 | + it "Has method: '#{method}'", -> |
| 23 | + expect(typeof scrollCSA[method]).toBe 'function' |
| 24 | + expect(typeof anchorCSA[method]).toBe 'function' |
| 25 | + |
| 26 | + 'willCollide pathCheck'.split(' ').forEach (method)-> |
| 27 | + it "Has path-based allocation method: '#{method}'", -> |
| 28 | + expect(typeof scrollCSA[method]).toBe 'function' |
| 29 | + expect(typeof anchorCSA[method]).toBe 'function' |
| 30 | + |
| 31 | + it 'successful initialization of comment manager', -> |
| 32 | + expect(manager).not.toBe null |
| 33 | + |
| 34 | + describe 'AnchorCommentSpaceAllocator', -> |
| 35 | + it 'comments always collide', -> |
| 36 | + expect(anchorCSA.willCollide(c1, c2)).toBe true |
| 37 | + it 'same comment must collide with self', -> |
| 38 | + expect(anchorCSA.willCollide(c1, c1)).toBe true |
| 39 | + expect(anchorCSA.willCollide(c2, c2)).toBe true |
| 40 | + it 'path check passes for y = 0 in empty pool', -> |
| 41 | + expect(anchorCSA.pathCheck(0, c1, [])).toBe true |
| 42 | + it 'path check fails for y = 0 in self pool', -> |
| 43 | + expect(anchorCSA.pathCheck(0, c1, [c1])).toBe false |
| 44 | + it 'path check fails for y = height + 1 in self pool', -> |
| 45 | + expect(anchorCSA.pathCheck(c1.height + 1, c1, [c1])).toBe true |
| 46 | + # TODO: We need more extensive test cases |
| 47 | + |
| 48 | + describe 'CommentSpaceAllocator', -> |
| 49 | + it 'same comment must collide with self', -> |
| 50 | + expect(scrollCSA.willCollide(s1, s1)).toBe true |
| 51 | + expect(scrollCSA.willCollide(s2, s2)).toBe true |
| 52 | + it 'path check passes for y = 0 in empty pool', -> |
| 53 | + expect(scrollCSA.pathCheck(0, s1, [])).toBe true |
| 54 | + it 'path check passes for y = 0 in self pool', -> |
| 55 | + expect(scrollCSA.pathCheck(0, s1, [s1])).toBe false |
| 56 | + it 'path check passes for y = height + 1 in self pool', -> |
| 57 | + expect(scrollCSA.pathCheck(s1.height + 1, s1, [s1])).toBe true |
| 58 | + # TODO: We need more extensive test cases |
0 commit comments