-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,58 @@ | ||
'use strict' | ||
describe 'CommentSpaceAllocators', -> | ||
scrollCSA = anchorCSA = manager = stage = c1 = c2 = s1 = s2 = null | ||
|
||
describe 'AnchorCommentSpaceAllocator', -> | ||
xit('TODO: add some examples to (or delete) it') | ||
describe 'instance ISpaceAllocator and descendants', -> | ||
beforeEach -> | ||
scrollCSA = new CommentSpaceAllocator(400,300) | ||
anchorCSA = new AnchorCommentSpaceAllocator(400,300) | ||
stage = document.createElement 'DIV' | ||
manager = new CommentManager(stage) | ||
manager.init() | ||
c1 = new CoreComment(manager, {}) | ||
c2 = new CoreComment(manager, {}) | ||
s1 = new ScrollComment(manager, {}) | ||
s2 = new ScrollComment(manager, {}) | ||
c1.init(); | ||
c2.init(); | ||
s1.init(); | ||
s2.init(); | ||
|
||
describe 'CommentSpaceAllocator', -> | ||
xit('TODO: add some examples to (or delete) it') | ||
'add remove setBounds'.split(' ').forEach (method)-> | ||
it "Has method: '#{method}'", -> | ||
expect(typeof scrollCSA[method]).toBe 'function' | ||
expect(typeof anchorCSA[method]).toBe 'function' | ||
|
||
'willCollide pathCheck'.split(' ').forEach (method)-> | ||
it "Has path-based allocation method: '#{method}'", -> | ||
expect(typeof scrollCSA[method]).toBe 'function' | ||
expect(typeof anchorCSA[method]).toBe 'function' | ||
|
||
it 'successful initialization of comment manager', -> | ||
expect(manager).not.toBe null | ||
|
||
describe 'AnchorCommentSpaceAllocator', -> | ||
it 'comments always collide', -> | ||
expect(anchorCSA.willCollide(c1, c2)).toBe true | ||
it 'same comment must collide with self', -> | ||
expect(anchorCSA.willCollide(c1, c1)).toBe true | ||
expect(anchorCSA.willCollide(c2, c2)).toBe true | ||
it 'path check passes for y = 0 in empty pool', -> | ||
expect(anchorCSA.pathCheck(0, c1, [])).toBe true | ||
it 'path check fails for y = 0 in self pool', -> | ||
expect(anchorCSA.pathCheck(0, c1, [c1])).toBe false | ||
it 'path check fails for y = height + 1 in self pool', -> | ||
expect(anchorCSA.pathCheck(c1.height + 1, c1, [c1])).toBe true | ||
# TODO: We need more extensive test cases | ||
|
||
describe 'CommentSpaceAllocator', -> | ||
it 'same comment must collide with self', -> | ||
expect(scrollCSA.willCollide(s1, s1)).toBe true | ||
expect(scrollCSA.willCollide(s2, s2)).toBe true | ||
it 'path check passes for y = 0 in empty pool', -> | ||
expect(scrollCSA.pathCheck(0, s1, [])).toBe true | ||
it 'path check passes for y = 0 in self pool', -> | ||
expect(scrollCSA.pathCheck(0, s1, [s1])).toBe false | ||
it 'path check passes for y = height + 1 in self pool', -> | ||
expect(scrollCSA.pathCheck(s1.height + 1, s1, [s1])).toBe true | ||
# TODO: We need more extensive test cases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters