Skip to content

Commit af37430

Browse files
author
Kaushik Shetty
committed
test: fix types in window unit
tests
1 parent 19b4ea5 commit af37430

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

__test__/frame.test.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import EventEmitter from "wolfy87-eventemitter";
2-
import Window from "../src/window";
32
import postRobot from "post-robot";
43

4+
import Window from "../src/window";
5+
import { DashboardWidth, LocationType } from "../src/types";
6+
57
jest.mock("post-robot", () => ({
68
__esModule: true,
79
default: {
@@ -33,12 +35,12 @@ describe("Window", () => {
3335

3436
connection = { sendToParent: sendToParent };
3537
jest.spyOn(connection, "sendToParent");
36-
windowObj = new Window(connection, "FIELD", emitter);
38+
windowObj = new Window(connection, LocationType.FIELD, emitter);
3739
});
3840

3941
it("enableResizing", (done) => {
40-
windowObj.type = "DASHBOARD";
41-
windowObj?.enableResizing().then(() => {
42+
windowObj.type = LocationType.DASHBOARD;
43+
windowObj.enableResizing().then(() => {
4244
expect(connection.sendToParent).toHaveBeenCalledWith("window", {
4345
action: "enableResizing",
4446
}); // since previous height was same
@@ -47,7 +49,7 @@ describe("Window", () => {
4749
});
4850

4951
it("enableResizing called on field extension", (done) => {
50-
windowObj.type = "FIELD";
52+
windowObj.type = LocationType.FIELD;
5153
windowObj.enableResizing().then(() => {
5254
expect(connection.sendToParent).toHaveBeenCalledTimes(0); // since previous height was same
5355
done();
@@ -62,8 +64,8 @@ describe("Window", () => {
6264
});
6365

6466
it("updateHeight for dashboard in half width", (done) => {
65-
windowObj.type = "DASHBOARD";
66-
windowObj.state = "half_width";
67+
windowObj.type = LocationType.DASHBOARD;
68+
windowObj.state = DashboardWidth.HALF_WIDTH;
6769
windowObj.updateHeight(55).then(() => {
6870
expect(connection.sendToParent).toHaveBeenCalledTimes(0);
6971
done();
@@ -91,22 +93,22 @@ describe("Window", () => {
9193
});
9294

9395
it("onDashboardResize Callback must be a function", function () {
94-
windowObj.type = "DASHBOARD";
96+
windowObj.type = LocationType.DASHBOARD;
9597
//@ts-ignore
9698
expect(() => windowObj.onDashboardResize()).toThrow(
9799
"Callback must be a function"
98100
);
99101
});
100102

101103
it("onDashboardResize for field extension", function () {
102-
windowObj.type = "FIELD";
104+
windowObj.type = LocationType.FIELD;
103105
//@ts-ignore
104106
expect(windowObj.onDashboardResize()).toEqual(false);
105107
});
106108

107109
it("onDashboardResize", function (done) {
108-
windowObj.type = "DASHBOARD";
109-
expect(windowObj.state).toEqual("half_width");
110+
windowObj.type = LocationType.DASHBOARD;
111+
expect(windowObj.state).toEqual(DashboardWidth.HALF_WIDTH);
110112
windowObj.onDashboardResize(function () {
111113
expect(emitter.on).toHaveBeenCalledWith(
112114
"dashboardResize",
@@ -119,7 +121,7 @@ describe("Window", () => {
119121
});
120122

121123
it("should send dashboardEnableTopPadding on enablePaddingTop", (done) => {
122-
windowObj.type = "DASHBOARD";
124+
windowObj.type = LocationType.DASHBOARD;
123125
windowObj.enablePaddingTop().then(() => {
124126
expect((postRobot as any).sendToParent).toHaveBeenCalledWith(
125127
"window",
@@ -132,7 +134,7 @@ describe("Window", () => {
132134
});
133135

134136
it("should send dashboardDisableTopPadding on disablePaddingTop", (done) => {
135-
windowObj.type = "DASHBOARD";
137+
windowObj.type = LocationType.DASHBOARD;
136138
windowObj.disablePaddingTop().then(() => {
137139
expect((postRobot as any).sendToParent).toHaveBeenCalledWith(
138140
"window",

0 commit comments

Comments
 (0)