Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions src/use-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 10 additions & 10 deletions test/use-connect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('useConnect', () => {
});

afterEach(() => {
delete global.window._ArcadiaConnect;
delete global.window._ArcConnect;
});

it('has the expected values on load', async () => {
Expand Down Expand Up @@ -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)
);
});
Expand All @@ -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)
);
});
Expand All @@ -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 () => {
Expand All @@ -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();
});
Expand All @@ -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);
});
});
});
Expand Down
16 changes: 8 additions & 8 deletions test/with-connect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('withConnect', () => {
it('can call open', async () => {
render(<MockCredentialComponentWithHOC {...props} />);
await clickOpen();
expect(window._ArcadiaConnect.create).toHaveBeenCalledWith(
expect(window._ArcConnect.create).toHaveBeenCalledWith(
expect.objectContaining(mockConfig)
);
});
Expand All @@ -110,12 +110,12 @@ describe('withConnect', () => {
);
render(<MockCredentialComponentWithHOC {...props} />);
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 () => {
Expand All @@ -124,7 +124,7 @@ describe('withConnect', () => {
);
render(<MockCredentialComponentWithHOC {...props} />);
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/);
});
Expand All @@ -136,7 +136,7 @@ describe('withConnect', () => {
render(<MockCredentialComponentWithHOC {...props} />);
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();
});
Expand All @@ -157,9 +157,9 @@ describe('withConnect', () => {
<MockCredentialComponentWithHOC {...props} />
);
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);
});
});
});
Expand Down
Loading