From 2c609be92465bd7e48ea1b8eab049866a7a06e83 Mon Sep 17 00:00:00 2001 From: Arvindraj Anguraju Date: Wed, 15 Apr 2026 20:54:13 +0530 Subject: [PATCH] reverts the renaming of factory window object --- package.json | 2 +- src/use-connect.js | 6 +++--- test/test-utils.js | 2 +- test/use-connect.test.js | 20 ++++++++++---------- test/with-connect.test.js | 16 ++++++++-------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 9116cc5..06e5176 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@arcadia-eng/connect-react", - "version": "7.2.1", + "version": "7.3.0", "description": "React package for implementing Legacy Arcadia Connect", "main": "dist/index.js", "scripts": { diff --git a/src/use-connect.js b/src/use-connect.js index de55979..3550a12 100644 --- a/src/use-connect.js +++ b/src/use-connect.js @@ -35,9 +35,9 @@ export const useConnect = () => { }); const pollForFactory = useCallback(() => { - const { _ArcadiaConnect } = window; - if (_ArcadiaConnect) { - setFactory(_ArcadiaConnect); + const { _ArcConnect } = window; + if (_ArcConnect) { + setFactory(_ArcConnect); return; } diff --git a/test/test-utils.js b/test/test-utils.js index 370ecbb..137ac4d 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -42,7 +42,7 @@ export const generateUseScriptMock = ({ if (throwScriptError) { setScriptError(new Error('Something went wrong')); } else if (loadArcadiaElementSuccessfully) { - window._ArcadiaConnect = mockConnect; + window._ArcConnect = mockConnect; } }; simulateLoad(); diff --git a/test/use-connect.test.js b/test/use-connect.test.js index 9c77261..d5596ea 100644 --- a/test/use-connect.test.js +++ b/test/use-connect.test.js @@ -14,7 +14,7 @@ describe('useConnect', () => { }); afterEach(() => { - delete global.window._ArcadiaConnect; + delete global.window._ArcConnect; }); it('has the expected values on load', async () => { @@ -61,7 +61,7 @@ describe('useConnect', () => { await act(async () => { await open(sampleConfig); }); - expect(window._ArcadiaConnect.create).toHaveBeenCalledWith( + expect(window._ArcConnect.create).toHaveBeenCalledWith( expect.objectContaining(sampleConfig) ); }); @@ -76,9 +76,9 @@ describe('useConnect', () => { await act(async () => { await open(sampleConfig); }); - expect(window._ArcadiaConnect).toBeUndefined(); - await waitFor(() => expect(window._ArcadiaConnect).not.toBeUndefined()); - expect(window._ArcadiaConnect.create).toHaveBeenCalledWith( + expect(window._ArcConnect).toBeUndefined(); + await waitFor(() => expect(window._ArcConnect).not.toBeUndefined()); + expect(window._ArcConnect.create).toHaveBeenCalledWith( expect.objectContaining(sampleConfig) ); }); @@ -96,11 +96,11 @@ describe('useConnect', () => { }); const [{ loading, error }] = result.current; expect(loading).toEqual(false); - expect(window._ArcadiaConnect.validate).toHaveBeenCalledWith(sampleConfig); + expect(window._ArcConnect.validate).toHaveBeenCalledWith(sampleConfig); expect(error.message).toMatch(/Error setting configuration variables/); expect(error.message).toMatch(/Missing \"connectToken\" value/); expect(error.message).toMatch(/Missing \"somethingImportant\" value/); - expect(window._ArcadiaConnect.create).not.toHaveBeenCalled(); + expect(window._ArcConnect.create).not.toHaveBeenCalled(); }); it("shows an error if Arcadia's create function fails for any reason", async () => { @@ -126,7 +126,7 @@ describe('useConnect', () => { await act(async () => { await open(sampleConfig); }); - const initializationObject = window._ArcadiaConnect.create.mock.calls[0][0]; + const initializationObject = window._ArcConnect.create.mock.calls[0][0]; act(() => { initializationObject.callbacks.onClose(); }); @@ -143,9 +143,9 @@ describe('useConnect', () => { it('can close the factory when the factory is loaded', async () => { const { result, unmount, waitFor } = renderHook(() => useConnect()); await waitFor(() => expect(result.current[0].loading).toEqual(false)); - expect(window._ArcadiaConnect.close).toHaveBeenCalledTimes(0); + expect(window._ArcConnect.close).toHaveBeenCalledTimes(0); unmount(); - expect(window._ArcadiaConnect.close).toHaveBeenCalledTimes(1); + expect(window._ArcConnect.close).toHaveBeenCalledTimes(1); }); }); }); diff --git a/test/with-connect.test.js b/test/with-connect.test.js index 924c8bf..07bb703 100644 --- a/test/with-connect.test.js +++ b/test/with-connect.test.js @@ -48,7 +48,7 @@ describe('withConnect', () => { }); afterEach(() => { - delete global.window._ArcadiaConnect; + delete global.window._ArcConnect; }); it("can forward props to the component it's wrapping", () => { @@ -99,7 +99,7 @@ describe('withConnect', () => { it('can call open', async () => { render(); await clickOpen(); - expect(window._ArcadiaConnect.create).toHaveBeenCalledWith( + expect(window._ArcConnect.create).toHaveBeenCalledWith( expect.objectContaining(mockConfig) ); }); @@ -110,12 +110,12 @@ describe('withConnect', () => { ); render(); await clickOpen(); - expect(window._ArcadiaConnect.validate).toHaveBeenCalledWith(mockConfig); + expect(window._ArcConnect.validate).toHaveBeenCalledWith(mockConfig); const alert = screen.getByRole('alert'); expect(alert).toHaveTextContent(/Error setting configuration variables/); expect(alert).toHaveTextContent(/Missing \"connectToken\" value/); expect(alert).toHaveTextContent(/Missing \"somethingImportant\" value/); - expect(window._ArcadiaConnect.create).not.toHaveBeenCalled(); + expect(window._ArcConnect.create).not.toHaveBeenCalled(); }); it("shows an error if Arcadia's create function fails for any reason", async () => { @@ -124,7 +124,7 @@ describe('withConnect', () => { ); render(); await clickOpen(); - expect(window._ArcadiaConnect.validate).toHaveBeenCalledWith(mockConfig); + expect(window._ArcConnect.validate).toHaveBeenCalledWith(mockConfig); const alert = screen.getByRole('alert'); expect(alert).toHaveTextContent(/Error loading Connect/); }); @@ -136,7 +136,7 @@ describe('withConnect', () => { render(); await clickOpen(); const initializationObject = - window._ArcadiaConnect.create.mock.calls[0][0]; + window._ArcConnect.create.mock.calls[0][0]; await act(async () => { await initializationObject.callbacks.onClose(); }); @@ -157,9 +157,9 @@ describe('withConnect', () => { ); await clickOpen(); - expect(window._ArcadiaConnect.close).toHaveBeenCalledTimes(0); + expect(window._ArcConnect.close).toHaveBeenCalledTimes(0); unmount(); - expect(window._ArcadiaConnect.close).toHaveBeenCalledTimes(1); + expect(window._ArcConnect.close).toHaveBeenCalledTimes(1); }); }); });