Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
expect(myApp.wasBootstrapped()).toEqual(true);
expect(myApp.wasMounted()).toEqual(true);
expect(myApp.wasUnmounted()).toEqual(true); // We try to unmount an application if it fails to mount.
expect(singleSpa.getMountedApps()).toEqual([]);
expect(singleSpa.getAppStatus('./mount-fails.app.js')).toEqual('SKIP_BECAUSE_BROKEN');
location.hash = '#not-mount-fails';
return singleSpa
.triggerAppChange()
.then(() => {
expect(myApp.wasUnmounted()).toEqual(true);
expect(singleSpa.getMountedApps()).toEqual([]);
expect(singleSpa.getAppStatus('./mount-fails.app.js')).toEqual('SKIP_BECAUSE_BROKEN');
})
})
});
.then(() => {
expect(myApp.numBootstraps()).toEqual(1);
expect(myApp.numMounts()).toEqual(1);
expect(singleSpa.getMountedApps()).toEqual(['./invalid-unmount.app.js']);
expect(singleSpa.getAppStatus('./invalid-unmount.app.js')).toEqual('MOUNTED');
// now unmount, which will be the first time it enters a broken state
location.hash = '#not-invalid-unmount';
return singleSpa
.triggerAppChange()
.then(() => {
expect(myApp.numBootstraps()).toEqual(1);
expect(myApp.numMounts()).toEqual(1);
expect(myApp.numUnmounts()).toEqual(1);
expect(singleSpa.getMountedApps()).toEqual([]);
expect(singleSpa.getAppStatus('./invalid-unmount.app.js')).toEqual('SKIP_BECAUSE_BROKEN');
// now remount and check if it tries to mount despite being in a broken state
location.hash = activeHash;
return singleSpa
.triggerAppChange()
.then(() => {
expect(myApp.bootstraps()).toEqual(1);
expect(myApp.mounts()).toEqual(1);
expect(singleSpa.getMountedApps()).toEqual(['./mount-times-out.app.js']);
expect(singleSpa.getAppStatus('./mount-times-out.app.js')).toEqual('MOUNTED');
})
});
.then(() => {
expect(myApp.isBootstrapped()).toEqual(false);
expect(singleSpa.getMountedApps()).toEqual([]);
expect(singleSpa.getAppStatus('./invalid-no-mount.app.js')).toEqual('SKIP_BECAUSE_BROKEN');
})
});
.then(() => {
expect(myApp.wasBootstrapped()).toEqual(true);
expect(myApp.wasMounted()).toEqual(false);
expect(singleSpa.getMountedApps()).toEqual([]);
expect(singleSpa.getAppStatus('./bootstrap-times-out-dies.app.js')).toEqual('SKIP_BECAUSE_BROKEN');
expect(errs.length).toBeGreaterThan(0);
})
});
.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);
window.location.hash = '#';
return singleSpa.triggerAppChange();
})
.then(() => {
.then(() => {
expect(myApp.isBootstrapped()).toEqual(false);
expect(myApp.isMounted()).toEqual(false);
expect(singleSpa.getMountedApps()).toEqual([]);
expect(singleSpa.getAppStatus('./invalid-no-unmount.app.js')).toEqual('SKIP_BECAUSE_BROKEN');
})
});