Skip to content

Commit

Permalink
test: combine prefetchScript with loadScript
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinmd committed Sep 30, 2024
1 parent cc7d25a commit 969d6d8
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,27 @@ describe('Federated', () => {
await ScriptManager.shared.loadScript('miniApp2');
expect(loadingScript2IsFinished).toEqual(true);
});

it('should wait loadScript and prefetchScript', async () => {
const cache = new FakeCache();
ScriptManager.shared.setStorage(cache);

ScriptManager.shared.addResolver(async (scriptId, caller) => {
return {
url: Script.getRemoteURL(scriptId),
cache: true,
};
});

let prefetchScriptIsFinished = false;

// loadScript should wait first time called loadScript although we are not awaited, because scriptId is same
ScriptManager.shared
.prefetchScript('miniApp')
.then(() => (prefetchScriptIsFinished = true));

await ScriptManager.shared.loadScript('miniApp');

expect(prefetchScriptIsFinished).toEqual(true);
});
});

0 comments on commit 969d6d8

Please sign in to comment.