Skip to content

Commit

Permalink
Merge pull request #60 from namecheap/feature/unload-ap
Browse files Browse the repository at this point in the history
feat: unload app method
  • Loading branch information
stas-nc authored Sep 6, 2024
2 parents a58d6d8 + c72047d commit fcfa19d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/app/GlobalBrowserApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class GlobalBrowserApi {
return window.ILC.loadApp(name, options);
}

static unloadApp(appId: string): void {
return window.ILC.unloadApp(appId);
}

static getApplicationConfig<T extends object>(name: string): Promise<ApplicationConfig<T> | undefined> {
return window.ILC.getApplicationConfigByName(name);
}
Expand Down
1 change: 1 addition & 0 deletions src/app/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare global {
interface Window {
ILC: {
loadApp: (name: string, options?: { injectGlobalCss?: boolean }) => Promise<LifeCycles>;
unloadApp: (appId: string) => void;
navigate: (url: string) => void;
onIntlChange: (handler: (intlValues: { locale: string; currency: string }) => any) => void;
onRouteChange: (
Expand Down
4 changes: 4 additions & 0 deletions test/app/GlobalBrowserApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('GlobalBrowserApi', () => {
getSharedLibConfigByName: () => Promise.resolve([]),
getSharedLibConfigByNameSync: () => [],
getApplicationConfigByName: <T>() => Promise.resolve(appConfig as ApplicationConfig<T>),
unloadApp: (appId) => Promise.resolve(),
};
});

Expand Down Expand Up @@ -112,6 +113,9 @@ describe('GlobalBrowserApi', () => {
const res = await GlobalBrowserApi.loadApp('@portal/news');
expect(res).to.deep.eq(app);
});
it('unloadApp is correctly typed and callable (no options arg)', async () => {
expect(GlobalBrowserApi.unloadApp('news_at_body')).to.be.fulfilled;
});
it('loadApp is correctly typed and callable (empty option arg)', async () => {
const res = await GlobalBrowserApi.loadApp('@portal/news', {});
expect(res).to.deep.eq(app);
Expand Down

0 comments on commit fcfa19d

Please sign in to comment.