This repository has been archived by the owner on Jan 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/tests' into develop
- Loading branch information
Showing
13 changed files
with
973 additions
and
25 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
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
describe("Base", function() { | ||
var view, paper, raphael, x, y; | ||
|
||
beforeEach( function() { | ||
x = 42; | ||
y = 24; | ||
raphael = Raphael(0, 0, 0, 0); | ||
paper = { | ||
set: jasmine.createSpy('set').andReturn(raphael.set()), | ||
circle: jasmine.createSpy('circle').andReturn(raphael.circle(x, y, 0)) | ||
}; | ||
view = new View.RaphaelBase(paper); | ||
}); | ||
|
||
afterEach( function() { | ||
view.kill(); | ||
}); | ||
|
||
describe("when constructed", function() { | ||
it("should have set the paper", function() { | ||
expect(view.paper).toBe(paper); | ||
}); | ||
|
||
it("should be able to get x and y when nothing is set", function() { | ||
expect(view.x).toEqual(0); | ||
expect(view.y).toEqual(0); | ||
}); | ||
|
||
describe("when drawn", function() { | ||
var contents; | ||
|
||
beforeEach( function() { | ||
spyOn(view, 'clear').andCallThrough(); | ||
contents = view.draw(x, y); | ||
}); | ||
|
||
it("should clear first", function() { | ||
expect(view.clear).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should have drawn and return the contents", function() { | ||
expect(contents).toBeDefined(); | ||
}); | ||
|
||
describe("when moved to a new fixed position", function() { | ||
beforeEach( function() { | ||
spyOn(view, 'move').andCallThrough(); | ||
view.moveTo(x, y); | ||
}); | ||
|
||
it("should have been moved", function() { | ||
expect(view.move).toHaveBeenCalled(); | ||
expect(view.x).toEqual(x); | ||
expect(view.y).toEqual(y); | ||
}); | ||
}); | ||
|
||
describe("when moved to a new position relative to its parent", function() { | ||
beforeEach( function() { | ||
spyOn(view, 'moveTo').andCallThrough(); | ||
view.setPosition(); | ||
}); | ||
|
||
it("should do nothing when parent is null", function() { | ||
expect(view.moveTo).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe("when redrawn", function() { | ||
beforeEach( function() { | ||
spyOn(view, 'draw'); | ||
view.redraw(); | ||
}); | ||
|
||
it("should have redrawn and return the contents", function() { | ||
expect(view.draw).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
describe("Modal", function() { | ||
describe("when constructed", function() { | ||
beforeEach( function() { | ||
header = ""; | ||
contents = {}; | ||
id = 1; | ||
classname = ""; | ||
view = new View.HTMLModal(header, contents, id, classname) | ||
}); | ||
|
||
it("should have set all the properties", function() { | ||
expect( view._header ).toBe( header ); | ||
expect( view._contents ).toBe( contents ); | ||
expect( view.id ).toBe( id ); | ||
expect( view._id ).toBe( id ); | ||
expect( view._elem ).toBeDefined(); | ||
}); | ||
|
||
describe("when showing", function() { | ||
beforeEach( function() { | ||
spyOn( view._elem, "modal" ); | ||
view.show(); | ||
}); | ||
|
||
it("should have set action to undefined", function() { | ||
expect( view._action ).toBe( undefined ); | ||
}); | ||
|
||
it("should have called modal", function() { | ||
expect( view._elem.modal ).toHaveBeenCalledWith( "show" ); | ||
}) | ||
}); | ||
|
||
describe("when hiding", function() { | ||
beforeEach( function() { | ||
spyOn( view._elem, "modal" ); | ||
view.hide(); | ||
}); | ||
|
||
it("should have called modal", function() { | ||
expect( view._elem.modal ).toHaveBeenCalledWith( "hide" ); | ||
}) | ||
}); | ||
|
||
describe("when toggling", function() { | ||
beforeEach( function() { | ||
spyOn( view._elem, "modal" ); | ||
view.toggle(); | ||
}); | ||
|
||
it("should have called modal", function() { | ||
expect( view._elem.modal ).toHaveBeenCalledWith( "toggle" ); | ||
}) | ||
}); | ||
|
||
describe("when binding to close", function() { | ||
beforeEach( function() { | ||
spyOn( view, "_bind" ); | ||
context = {}; | ||
action = {}; | ||
view.onClose( context, action ); | ||
}); | ||
|
||
it("should have called bind", function() { | ||
expect( view._bind ).toHaveBeenCalledWith( "modal.confirm.close", context, action ); | ||
}); | ||
}); | ||
|
||
describe("when unbinding to close", function() { | ||
beforeEach( function() { | ||
spyOn( view, "_unbind" ); | ||
context = {}; | ||
action = {}; | ||
view.offClose( context, action ); | ||
}); | ||
|
||
it("should have called unbind", function() { | ||
expect( view._unbind ).toHaveBeenCalledWith( "modal.confirm.close", context, action ); | ||
}); | ||
}); | ||
|
||
describe("when binding to closed", function() { | ||
beforeEach( function() { | ||
spyOn( view, "_bind" ); | ||
context = {}; | ||
action = {}; | ||
view.onClosed( context, action ); | ||
}); | ||
|
||
it("should have called bind", function() { | ||
expect( view._bind ).toHaveBeenCalledWith( "modal.confirm.closed", context, action ); | ||
}); | ||
}); | ||
|
||
describe("when unbinding to closed", function() { | ||
beforeEach( function() { | ||
spyOn( view, "_unbind" ); | ||
context = {}; | ||
action = {}; | ||
view.offClosed( context, action ); | ||
}); | ||
|
||
it("should have called unbind", function() { | ||
expect( view._unbind ).toHaveBeenCalledWith( "modal.confirm.closed", context, action ); | ||
}); | ||
}); | ||
|
||
afterEach( function() { | ||
view.kill(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe("ConfirmModal", function() { | ||
describe("when constructed", function() { | ||
beforeEach( function() { | ||
header = ""; | ||
contents = {}; | ||
id = 1; | ||
classname = ""; | ||
view = new View.ConfirmModal(header, contents, id, classname) | ||
}); | ||
|
||
it("the modal should have a cancel button", function() { | ||
expect( view._elem.find("[data-action=\"cancel\"]").length ).toBe( 1 ); | ||
}); | ||
|
||
it("the modal should have a confirm button", function() { | ||
expect( view._elem.find("[data-action=\"confirm\"]").length ).toBe( 1 ); | ||
}); | ||
|
||
afterEach( function() { | ||
view.kill(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.