[Windowing] Unit Test

Unit Tests for UrlService and NewTabAction
created and partially written. UrlService
returns 100% and NewTabAction returns 88%.
WTD 16.
This commit is contained in:
Shivam Dave
2015-06-24 11:32:59 -07:00
parent 83cc0b65d5
commit 43cfab1031
6 changed files with 97 additions and 14 deletions

View File

@@ -28,24 +28,37 @@ define(
describe("The new tab action", function () {
var action,
action2,
mockWindow,
mockCurrentUrl;
mockDomainObject,
mockContext,
mock2Context,
mockUrlService;
beforeEach(function () {
// Creates a mockWindow from $window, then
// the mockWindow's location.href is set
// to a mock Url
mockWindow = jasmine.createSpyObj("$window", ["open", "location"]);
mockWindow.location.href = "http://www.mockUrl.com";
action = new NewTabAction(mockWindow);
mockWindow = jasmine.createSpyObj("$window", ["open", "location"]);
mockContext = jasmine.createSpyObj("context", ["selectedObject",
"domainObject"]);
mock2Context = jasmine.createSpyObj("context", ["domainObject"]);
mockUrlService = jasmine.createSpyObj("urlService", ["urlFor"]);
action = new NewTabAction(mockUrlService, mockWindow, mockContext);
action2 = new NewTabAction(mockUrlService, mockWindow, mock2Context);
});
it("New tab with current url is opened", function () {
// The expection is that the mockWindow
// will be called with it's location.href
action.perform();
expect(mockWindow.open).toHaveBeenCalledWith("http://www.mockUrl.com");
action2.perform();
});
});