Add functionality to allow users to add hideParameters to the url, which will hide tree and/or the inspector

New Tab automatically appends hideTree and hideInspector params to hide those panes by default
Add appropriate tests for new functionality and fix broken tests
This commit is contained in:
Deep Tailor
2017-08-10 10:30:05 -07:00
committed by Deep Tailor
parent 5ac377ec6a
commit c472ab044b
9 changed files with 62 additions and 17 deletions

View File

@ -29,7 +29,9 @@ define(
mockAgentService,
mockDomainObjects,
mockWindow,
controller;
controller,
mockLocation,
mockAttrs;
// We want to reinstantiate for each test case
// because device state can influence constructor-time behavior
@ -37,7 +39,9 @@ define(
return new PaneController(
mockScope,
mockAgentService,
mockWindow
mockWindow,
mockLocation,
mockAttrs
);
}
@ -59,6 +63,11 @@ define(
["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"]
);
mockWindow = jasmine.createSpyObj("$window", ["open"]);
mockLocation = jasmine.createSpyObj('location', ['search']);
mockLocation.search.andReturn({});
mockAttrs = {};
});
it("is initially visible", function () {
@ -86,6 +95,24 @@ define(
// Tree should have collapsed
expect(controller.visible()).toBeFalsy();
});
describe("specifying hideParameter", function () {
beforeEach(function () {
mockAttrs = {hideParameter: 'hideTree'};
});
it("sets pane state to false when in location.search", function () {
mockLocation.search.andReturn({'hideTree': true});
expect(instantiateController().visible()).toBe(false);
expect(mockLocation.search).toHaveBeenCalledWith('hideTree', undefined);
});
it("sets state to true when not found in location.search", function () {
mockLocation.search.andReturn({});
expect(instantiateController().visible()).toBe(true);
expect(mockLocation.search).not.toHaveBeenCalledWith('hideTree', undefined);
});
});
});
}
);