Skip to content

Commit

Permalink
fix: test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinmd committed Oct 29, 2024
1 parent a120a3e commit 664377e
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ describe('ScriptManagerAPI', () => {
await ScriptManager.shared.loadScript('miniApp');

expect(loadingScriptIsFinished).toEqual(true);
spy.mockReset();

spy.mockRestore();
});

Expand Down Expand Up @@ -810,7 +810,7 @@ describe('ScriptManagerAPI', () => {
expect(loadingScriptIsFinished).toEqual(true);
await ScriptManager.shared.loadScript('miniApp2');
expect(loadingScript2IsFinished).toEqual(true);
spy.mockReset();

spy.mockRestore();
});

Expand All @@ -836,15 +836,15 @@ describe('ScriptManagerAPI', () => {
await ScriptManager.shared.loadScript('miniApp');

expect(prefetchScriptIsFinished).toEqual(true);
spy.mockReset();

spy.mockRestore();
});

it('should refetch failed script', async () => {
jest.useFakeTimers({ advanceTimers: true });
const spy = jest.spyOn(NativeScriptManager, 'loadScript');

spy.mockImplementation(
spy.mockRejectedValueOnce(
(_scriptId: string, _scriptConfig: NormalizedScriptLocator) =>
Promise.reject({ code: 'NetworkFailed' })
);
Expand All @@ -866,14 +866,11 @@ describe('ScriptManagerAPI', () => {
// //expected to cache be empty
expect(Object.keys(cache.data).length).toBe(0);

await expect(async () =>
ScriptManager.shared.loadScript('miniApp')
).rejects.toThrow();
await ScriptManager.shared.loadScript('miniApp');

// expected to fetch again
// expect(spy.mock.lastCall?.[1].fetch).toBe(true);
expect(spy.mock.lastCall?.[1].fetch).toBe(true);

spy.mockReset();
spy.mockRestore();
});
});
Expand Down

0 comments on commit 664377e

Please sign in to comment.