2020-09-22 12:19:06 -07:00
|
|
|
import { getDataExplorerWindow } from "./WindowUtils";
|
|
|
|
|
2020-10-16 16:01:41 -05:00
|
|
|
interface MockWindow {
|
|
|
|
parent?: MockWindow;
|
|
|
|
top?: MockWindow;
|
|
|
|
}
|
2020-09-22 12:19:06 -07:00
|
|
|
|
|
|
|
describe("WindowUtils", () => {
|
|
|
|
describe("getDataExplorerWindow", () => {
|
2020-10-16 16:01:41 -05:00
|
|
|
it("should return undefined if current window is at the top", () => {
|
|
|
|
const mockWindow: MockWindow = {};
|
|
|
|
mockWindow.parent = mockWindow;
|
2020-09-22 12:19:06 -07:00
|
|
|
|
2020-10-16 16:01:41 -05:00
|
|
|
expect(getDataExplorerWindow(mockWindow as Window)).toEqual(undefined);
|
2020-09-22 12:19:06 -07:00
|
|
|
});
|
|
|
|
|
2020-10-16 16:01:41 -05:00
|
|
|
it("should return current window if parent is top", () => {
|
|
|
|
const dataExplorerWindow: MockWindow = {};
|
|
|
|
const portalWindow: MockWindow = {};
|
|
|
|
dataExplorerWindow.parent = portalWindow;
|
|
|
|
dataExplorerWindow.top = portalWindow;
|
2020-09-22 12:19:06 -07:00
|
|
|
|
2020-10-16 16:01:41 -05:00
|
|
|
expect(getDataExplorerWindow(dataExplorerWindow as Window)).toEqual(dataExplorerWindow);
|
2020-09-22 12:19:06 -07:00
|
|
|
});
|
|
|
|
|
2020-10-16 16:01:41 -05:00
|
|
|
it("should return closest window to top if in nested windows", () => {
|
|
|
|
const terminalWindow: MockWindow = {};
|
|
|
|
const dataExplorerWindow: MockWindow = {};
|
|
|
|
const portalWindow: MockWindow = {};
|
|
|
|
dataExplorerWindow.top = portalWindow;
|
|
|
|
dataExplorerWindow.parent = portalWindow;
|
|
|
|
terminalWindow.top = portalWindow;
|
|
|
|
terminalWindow.parent = dataExplorerWindow;
|
|
|
|
|
|
|
|
expect(getDataExplorerWindow(terminalWindow as Window)).toEqual(dataExplorerWindow);
|
|
|
|
expect(getDataExplorerWindow(dataExplorerWindow as Window)).toEqual(dataExplorerWindow);
|
2020-09-22 12:19:06 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|