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 18e15bd
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
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,13 @@ 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 18e15bd

Please sign in to comment.