Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
// First caller to unloadApplication wants to waitForUnmount
const promise1 = singleSpa.unloadApplication('./happy-unload.app.js', {waitForUnmount: true})
// Second caller to unloadApplication doesn't want to waitForUnmount
const promise2 = singleSpa.unloadApplication('./happy-unload.app.js', {waitForUnmount: false})
return Promise.all([promise1, promise2])
})
});
expect(() => {
// Trying to unload an app that doesn't exist
singleSpa.unloadApplication("App that doesn't exist");
}).toThrow()
});
.then(() => {
// First caller to unloadApplication wants to waitForUnmount
const promise1 = singleSpa.unloadApplication('./happy-unload.app.js', {waitForUnmount: true})
// Second caller to unloadApplication doesn't want to waitForUnmount
const promise2 = singleSpa.unloadApplication('./happy-unload.app.js', {waitForUnmount: false})
return Promise.all([promise1, promise2])
})
});
.then(() => {
// The unload lifecycle hasn't been called yet, so single-spa doesn't know it is a bad impl yet.
expect(singleSpa.getAppStatus('./invalid-unload.app.js')).toBe('MOUNTED');
return singleSpa.unloadApplication('./invalid-unload.app.js');
})
.then(() => {
.then(() => {
expect(singleSpa.getAppStatus('./happy-unload.app.js')).toEqual('MOUNTED');
expect(myApp.getNumBootstrapCalls()).toBe(1);
expect(myApp.getNumMountCalls()).toBe(1);
expect(myApp.getNumUnmountCalls()).toBe(0);
expect(myApp.getNumUnloadCalls()).toBe(0);
originalUnloadPromise = singleSpa
.unloadApplication('./happy-unload.app.js', {waitForUnmount: true})
.then(() => {
/* This will get called only once the app is unloaded. And it will not
* wait for the app to get remounted before it is called.
*/
expect(singleSpa.getAppStatus('./happy-unload.app.js')).toEqual('NOT_LOADED');
expect(myApp.getNumBootstrapCalls()).toBe(1);
expect(myApp.getNumMountCalls()).toBe(1);
expect(myApp.getNumUnmountCalls()).toBe(1);
expect(myApp.getNumUnloadCalls()).toBe(1);
})
/* Triggering an app change after calling unloadApplication will
* not cause the app to unload, since it is still mounted and we set
* waitForUnmount: true.
expect(() => {
// The parameters are in the reverse order
singleSpa.unloadApplication({waitForUnmount}, './invalid-unload.app.js');
}).toThrow()
.then(() => singleSpa.unloadApplication('lifecycle-props-customProps'))
.then(() => {
.then(() => {
return singleSpa.unloadApplication('lifecycle-props');
})
.then(() => {
afterEach(() => {
singleSpa.removeErrorHandler(handleError);
return singleSpa.unloadApplication("warning-timeouts");
});
.then(() => singleSpa.unloadApplication('./happy-unload.app.js'))
.then(() => {