-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: record deleted props in snapshotSandbox (#2869)
- Loading branch information
1 parent
393df3d
commit 77331e8
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import SnapshotSandbox from '../snapshotSandbox'; | ||
|
||
it('modify, add and delete props should isolated at sandbox', () => { | ||
window.globalProps = { a: 1 }; | ||
window.globalDeletedProps = { b: [] }; | ||
const sandbox1 = new SnapshotSandbox('app1'); | ||
const sandbox2 = new SnapshotSandbox('app2'); | ||
sandbox1.active(); | ||
window.globalProps = { a: 2 }; | ||
window.globalAddedProps = 3; | ||
delete window.globalDeletedProps; | ||
sandbox1.inactive(); | ||
// change to sandbox2 | ||
sandbox2.active(); | ||
expect(window.globalProps).toEqual({ a: 1 }); | ||
expect(window.globalAddedProps).not.toBeDefined(); | ||
expect(window.globalDeletedProps).toEqual({ b: [] }); | ||
sandbox2.inactive(); | ||
// restore sandbox1 | ||
sandbox1.active(); | ||
expect(window.globalProps).toEqual({ a: 2 }); | ||
expect(window.globalAddedProps).toEqual(3); | ||
expect(window.globalDeletedProps).not.toBeDefined(); | ||
// add delete props | ||
window.globalDeletedProps = { b: [2] }; | ||
sandbox1.inactive(); | ||
expect(window.globalDeletedProps).toEqual({ b: [] }); | ||
sandbox1.active(); | ||
expect(window.globalDeletedProps).toEqual({ b: [2] }); | ||
// delete props again | ||
delete window.globalDeletedProps; | ||
sandbox1.inactive(); | ||
expect(window.globalDeletedProps).toEqual({ b: [] }); | ||
sandbox1.active(); | ||
expect(window.globalDeletedProps).not.toBeDefined(); | ||
// 1. add props 2. modify props 2. delete props | ||
window.globalDeletedProps = { b: [2] }; | ||
window.globalDeletedProps = { b: [3] }; | ||
delete window.globalDeletedProps; | ||
sandbox1.inactive(); | ||
expect(window.globalDeletedProps).toEqual({ b: [] }); | ||
sandbox1.active(); | ||
expect(window.globalDeletedProps).not.toBeDefined(); | ||
// 1. delete props 2. add props 3. modify props | ||
delete window.globalAddedProps; | ||
window.globalAddedProps = 3; | ||
window.globalAddedProps = 4; | ||
sandbox1.inactive(); | ||
expect(window.globalAddedProps).not.toBeDefined(); | ||
sandbox1.active(); | ||
expect(window.globalAddedProps).toEqual(4); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77331e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
qiankun – ./
qiankun-chencheng.vercel.app
qiankun.vercel.app
qiankun-git-master-chencheng.vercel.app
qiankun.umijs.org