Skip to content

Commit 127b72f

Browse files
author
Kaushik Shetty
committed
fix!: replace all occurences of extension with ui locations
1 parent f159755 commit 127b72f

File tree

23 files changed

+2204
-1051
lines changed

23 files changed

+2204
-1051
lines changed

__test__/frame.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("Window", () => {
4848
});
4949
});
5050

51-
it("enableResizing called on field extension", (done) => {
51+
it("enableResizing called on Custom Field UI location", (done) => {
5252
windowObj.type = LocationType.FIELD;
5353
windowObj.enableResizing().then(() => {
5454
expect(connection.sendToParent).toHaveBeenCalledTimes(0); // since previous height was same
@@ -94,16 +94,14 @@ describe("Window", () => {
9494

9595
it("onDashboardResize Callback must be a function", function () {
9696
windowObj.type = LocationType.DASHBOARD;
97-
//@ts-ignore
98-
expect(() => windowObj.onDashboardResize()).toThrow(
97+
expect(() => windowObj.onDashboardResize(undefined as any)).toThrow(
9998
"Callback must be a function"
10099
);
101100
});
102101

103-
it("onDashboardResize for field extension", function () {
102+
it("onDashboardResize for Custom Field UI location", function () {
104103
windowObj.type = LocationType.FIELD;
105-
//@ts-ignore
106-
expect(windowObj.onDashboardResize()).toEqual(false);
104+
expect(windowObj.onDashboardResize(undefined as any)).toEqual(false);
107105
});
108106

109107
it("onDashboardResize", function (done) {

__test__/init.test.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import ContentstackAppSDK from "../src/index";
2-
import Extension from "../src/extension";
2+
import UiLocation from "../src/uiLocation";
33
import { version } from "../package.json";
44

5-
jest.mock("../src/extension");
5+
jest.mock("../src/uiLocation");
66

77
describe("ContentstackAppSDK", () => {
88
describe("init", () => {
@@ -11,36 +11,38 @@ describe("ContentstackAppSDK", () => {
1111
};
1212
beforeEach(() => {
1313
const mockInitialize = jest.fn().mockResolvedValue(mockInitData);
14-
Extension.initialize = mockInitialize;
14+
UiLocation.initialize = mockInitialize;
1515
});
1616

1717
afterEach(() => {
1818
// Reset the static variable after every test
19-
(ContentstackAppSDK._extension as any) = undefined;
19+
(ContentstackAppSDK._uiLocation as any) = undefined;
2020
jest.resetAllMocks();
2121
});
2222

23-
it("should initialize the extension and return an instance of Extension", async () => {
24-
const extension = await ContentstackAppSDK.init();
23+
it("should initialize the ui location and return an instance of Location", async () => {
24+
const uiLocation = await ContentstackAppSDK.init();
2525

26-
expect(Extension.initialize).toHaveBeenCalledTimes(1);
27-
expect(Extension.initialize).toBeCalledWith(version);
28-
expect(Extension).toHaveBeenCalledWith(mockInitData);
29-
expect(extension).toBeInstanceOf(Extension);
26+
expect(UiLocation.initialize).toHaveBeenCalledTimes(1);
27+
expect(UiLocation.initialize).toBeCalledWith(version);
28+
expect(UiLocation).toHaveBeenCalledWith(mockInitData);
29+
expect(uiLocation).toBeInstanceOf(UiLocation);
3030
});
3131

32-
it("should return the same instance of Extension if it has already been initialized", async () => {
33-
(Extension.initialize as jest.Mock).mockResolvedValue(mockInitData);
34-
const extension = await ContentstackAppSDK.init();
35-
const extension2 = await ContentstackAppSDK.init();
32+
it("should return the same instance of Location if it has already been initialized", async () => {
33+
(UiLocation.initialize as jest.Mock).mockResolvedValue(
34+
mockInitData
35+
);
36+
const uiLocation = await ContentstackAppSDK.init();
37+
const uiLocation2 = await ContentstackAppSDK.init();
3638

37-
expect(Extension.initialize).toHaveBeenCalledTimes(1);
38-
expect(extension).toBe(extension2);
39+
expect(UiLocation.initialize).toHaveBeenCalledTimes(1);
40+
expect(uiLocation).toBe(uiLocation2);
3941
});
4042

4143
it("should reject the promise if initialization fails", async () => {
4244
const error = new Error("Initialization failed");
43-
(Extension.initialize as jest.Mock).mockRejectedValue(error);
45+
(UiLocation.initialize as jest.Mock).mockRejectedValue(error);
4446

4547
await expect(ContentstackAppSDK.init()).rejects.toThrow(error);
4648
});

0 commit comments

Comments
 (0)