mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +00:00
[Info Service] Update spec
...to reflect usage of popupService.
This commit is contained in:
parent
553b17fafe
commit
99048a4ee3
@ -28,117 +28,85 @@ define(
|
|||||||
|
|
||||||
describe("The info service", function () {
|
describe("The info service", function () {
|
||||||
var mockCompile,
|
var mockCompile,
|
||||||
mockDocument,
|
|
||||||
testWindow,
|
|
||||||
mockRootScope,
|
mockRootScope,
|
||||||
|
mockPopupService,
|
||||||
mockAgentService,
|
mockAgentService,
|
||||||
mockCompiledTemplate,
|
mockScope,
|
||||||
testScope,
|
mockElements,
|
||||||
mockBody,
|
mockPopup,
|
||||||
mockElement,
|
|
||||||
service;
|
service;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockCompile = jasmine.createSpy('$compile');
|
mockCompile = jasmine.createSpy('$compile');
|
||||||
mockDocument = jasmine.createSpyObj('$document', ['find']);
|
|
||||||
testWindow = { innerWidth: 1000, innerHeight: 100 };
|
|
||||||
mockRootScope = jasmine.createSpyObj('$rootScope', ['$new']);
|
mockRootScope = jasmine.createSpyObj('$rootScope', ['$new']);
|
||||||
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']);
|
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']);
|
||||||
mockCompiledTemplate = jasmine.createSpy('template');
|
mockPopupService = jasmine.createSpyObj(
|
||||||
testScope = {};
|
'popupService',
|
||||||
mockBody = jasmine.createSpyObj('body', ['append']);
|
['display']
|
||||||
mockElement = jasmine.createSpyObj('element', ['css', 'remove']);
|
);
|
||||||
|
mockPopup = jasmine.createSpyObj('popup', [
|
||||||
|
'dismiss',
|
||||||
|
'goesLeft',
|
||||||
|
'goesRight',
|
||||||
|
'goesUp',
|
||||||
|
'goesDown'
|
||||||
|
]);
|
||||||
|
|
||||||
mockDocument.find.andCallFake(function (tag) {
|
mockScope = jasmine.createSpyObj("scope", ["$destroy"]);
|
||||||
return tag === 'body' ? mockBody : undefined;
|
mockElements = [];
|
||||||
|
|
||||||
|
mockPopupService.display.andReturn(mockPopup);
|
||||||
|
mockCompile.andCallFake(function () {
|
||||||
|
var mockCompiledTemplate = jasmine.createSpy('template'),
|
||||||
|
mockElement = jasmine.createSpyObj('element', [
|
||||||
|
'css',
|
||||||
|
'remove',
|
||||||
|
'append'
|
||||||
|
]);
|
||||||
|
mockCompiledTemplate.andReturn(mockElement);
|
||||||
|
mockElements.push(mockElement);
|
||||||
|
return mockCompiledTemplate;
|
||||||
});
|
});
|
||||||
mockCompile.andReturn(mockCompiledTemplate);
|
mockRootScope.$new.andReturn(mockScope);
|
||||||
mockCompiledTemplate.andReturn(mockElement);
|
|
||||||
mockRootScope.$new.andReturn(testScope);
|
|
||||||
|
|
||||||
service = new InfoService(
|
service = new InfoService(
|
||||||
mockCompile,
|
mockCompile,
|
||||||
mockDocument,
|
|
||||||
testWindow,
|
|
||||||
mockRootScope,
|
mockRootScope,
|
||||||
|
mockPopupService,
|
||||||
mockAgentService
|
mockAgentService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates elements and appends them to the body to display", function () {
|
it("creates elements and displays them as popups", function () {
|
||||||
service.display('', '', {}, [0, 0]);
|
service.display('', '', {}, [123, 456]);
|
||||||
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
|
expect(mockPopupService.display).toHaveBeenCalledWith(
|
||||||
|
mockElements[0],
|
||||||
|
[ 123, 456 ],
|
||||||
|
jasmine.any(Object)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("provides a function to remove displayed info bubbles", function () {
|
it("provides a function to remove displayed info bubbles", function () {
|
||||||
var fn = service.display('', '', {}, [0, 0]);
|
var fn = service.display('', '', {}, [0, 0]);
|
||||||
expect(mockElement.remove).not.toHaveBeenCalled();
|
expect(mockPopup.dismiss).not.toHaveBeenCalled();
|
||||||
fn();
|
fn();
|
||||||
expect(mockElement.remove).toHaveBeenCalled();
|
expect(mockPopup.dismiss).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("depending on mouse position", function () {
|
it("when on phone device, positions at bottom", function () {
|
||||||
// Positioning should vary based on quadrant in window,
|
mockAgentService.isPhone.andReturn(true);
|
||||||
// which is 1000 x 100 in this test case.
|
service = new InfoService(
|
||||||
it("displays from the top-left in the top-left quadrant", function () {
|
mockCompile,
|
||||||
service.display('', '', {}, [250, 25]);
|
mockRootScope,
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
mockPopupService,
|
||||||
'left',
|
mockAgentService
|
||||||
(250 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
|
);
|
||||||
);
|
service.display('', '', {}, [123, 456]);
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
expect(mockPopupService.display).toHaveBeenCalledWith(
|
||||||
'top',
|
mockElements[0],
|
||||||
(25 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
|
[ 0, -25 ],
|
||||||
);
|
jasmine.any(Object)
|
||||||
});
|
);
|
||||||
|
|
||||||
it("displays from the top-right in the top-right quadrant", function () {
|
|
||||||
service.display('', '', {}, [700, 25]);
|
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
|
||||||
'right',
|
|
||||||
(300 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
|
|
||||||
);
|
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
|
||||||
'top',
|
|
||||||
(25 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("displays from the bottom-left in the bottom-left quadrant", function () {
|
|
||||||
service.display('', '', {}, [250, 70]);
|
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
|
||||||
'left',
|
|
||||||
(250 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
|
|
||||||
);
|
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
|
||||||
'bottom',
|
|
||||||
(30 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("displays from the bottom-right in the bottom-right quadrant", function () {
|
|
||||||
service.display('', '', {}, [800, 60]);
|
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
|
||||||
'right',
|
|
||||||
(200 + InfoConstants.BUBBLE_OFFSET[0]) + 'px'
|
|
||||||
);
|
|
||||||
expect(mockElement.css).toHaveBeenCalledWith(
|
|
||||||
'bottom',
|
|
||||||
(40 + InfoConstants.BUBBLE_OFFSET[1]) + 'px'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("when on phone device, positioning is always on bottom", function () {
|
|
||||||
mockAgentService.isPhone.andReturn(true);
|
|
||||||
service = new InfoService(
|
|
||||||
mockCompile,
|
|
||||||
mockDocument,
|
|
||||||
testWindow,
|
|
||||||
mockRootScope,
|
|
||||||
mockAgentService
|
|
||||||
);
|
|
||||||
service.display('', '', {}, [0, 0]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user