mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 15:26:39 +00:00
[Common UI] Test popupService
This commit is contained in:
parent
a1d1261179
commit
1ca2b769d9
@ -86,12 +86,6 @@ define(
|
|||||||
offset,
|
offset,
|
||||||
bubble;
|
bubble;
|
||||||
|
|
||||||
function applyClassOption(direction) {
|
|
||||||
if (options[direction + 'Class']) {
|
|
||||||
element.addClass(options[direction + 'Class']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function adjustNegatives(value, index) {
|
function adjustNegatives(value, index) {
|
||||||
return value < 0 ? (value + winDim[index]) : value;
|
return value < 0 ? (value + winDim[index]) : value;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,72 @@ define(
|
|||||||
function (PopupService) {
|
function (PopupService) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
describe("PopupService", function () {
|
||||||
|
var mockDocument,
|
||||||
|
testWindow,
|
||||||
|
mockBody,
|
||||||
|
mockElement,
|
||||||
|
popupService;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockDocument = jasmine.createSpyObj('$document', [ 'find' ]);
|
||||||
|
testWindow = { innerWidth: 1000, innerHeight: 800 };
|
||||||
|
mockBody = jasmine.createSpyObj('body', [ 'append' ]);
|
||||||
|
mockElement = jasmine.createSpyObj('element', [
|
||||||
|
'css',
|
||||||
|
'remove'
|
||||||
|
]);
|
||||||
|
|
||||||
|
mockDocument.find.andCallFake(function (query) {
|
||||||
|
return query === 'body' && mockBody;
|
||||||
|
});
|
||||||
|
|
||||||
|
popupService = new PopupService(mockDocument, testWindow);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("adds elements to the body of the document", function () {
|
||||||
|
popupService.display(mockElement, [ 0, 0 ]);
|
||||||
|
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when positioned in appropriate quadrants", function () {
|
||||||
|
it("orients elements relative to the top-left", function () {
|
||||||
|
popupService.display(mockElement, [ 25, 50 ]);
|
||||||
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
|
position: 'absolute',
|
||||||
|
left: '25px',
|
||||||
|
top: '50px'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("orients elements relative to the top-right", function () {
|
||||||
|
popupService.display(mockElement, [ 800, 50 ]);
|
||||||
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
|
position: 'absolute',
|
||||||
|
right: '200px',
|
||||||
|
top: '50px'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("orients elements relative to the bottom-right", function () {
|
||||||
|
popupService.display(mockElement, [ 800, 650 ]);
|
||||||
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
|
position: 'absolute',
|
||||||
|
right: '200px',
|
||||||
|
bottom: '150px'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("orients elements relative to the bottom-left", function () {
|
||||||
|
popupService.display(mockElement, [ 120, 650 ]);
|
||||||
|
expect(mockElement.css).toHaveBeenCalledWith({
|
||||||
|
position: 'absolute',
|
||||||
|
left: '120px',
|
||||||
|
bottom: '150px'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user