Skip to content

Commit

Permalink
fix individual useManagedStorageState tests, no including test intefe…
Browse files Browse the repository at this point in the history
…rence
  • Loading branch information
mnholtz committed Oct 10, 2024
1 parent 083ee39 commit 2dfd26d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/store/enterprise/useManagedStorageState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,28 @@ describe("useManagedStorageState", () => {
});

it("handles already initialized state", async () => {
await browser.storage.managed.set({ partnerId: "foo" });
const expectedPolicy = { partnerId: "foo" };
await browser.storage.managed.set(expectedPolicy);

const { result, waitForNextUpdate } = renderHook(() =>
useManagedStorageState(),
);

await waitForNextUpdate();

Check failure on line 54 in src/store/enterprise/useManagedStorageState.test.ts

View workflow job for this annotation

GitHub Actions / test

useManagedStorageState › handles already initialized state

Timed out in waitForNextUpdate after 1000ms. at waitForNextUpdate (node_modules/@testing-library/react-hooks/lib/core/asyncUtils.js:96:13) at Object.<anonymous> (src/store/enterprise/useManagedStorageState.test.ts:54:5)

expect(result.current).toStrictEqual(
valueToAsyncState({ partnerId: "foo" }),
);
expect(result.current).toStrictEqual(valueToAsyncState(expectedPolicy));
});

// Can't test because mock doesn't fire change events: https://github.com/clarkbw/jest-webextension-mock/issues/170
it.skip("listens for changes", async () => {
it("listens for changes", async () => {
const { result, waitForNextUpdate } = renderHook(() =>
useManagedStorageState(),
);
expect(result.current.data).toBeUndefined();

Check failure on line 63 in src/store/enterprise/useManagedStorageState.test.ts

View workflow job for this annotation

GitHub Actions / test

useManagedStorageState › listens for changes

expect(received).toBeUndefined() Received: {} at Object.toBeUndefined (src/store/enterprise/useManagedStorageState.test.ts:63:33)
await browser.storage.managed.set({ partnerId: "taco-bell" });

const expectedPolicy = { partnerId: "foo" };
await browser.storage.managed.set(expectedPolicy);

await waitForNextUpdate();
expect(result.current).toStrictEqual({
data: { partnerId: "taco-bell" },
isLoading: false,
});
expect(result.current).toStrictEqual(valueToAsyncState(expectedPolicy));
});
});

0 comments on commit 2dfd26d

Please sign in to comment.