-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix issue for null values in the alignFields util
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/g6/__tests__/bugs/plugin-history-align-fields.spec.ts
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,42 @@ | ||
import { createGraph } from '@@/utils'; | ||
|
||
describe('bug: plugin-history-align-fields', () => { | ||
it('fix alignFields util', async () => { | ||
const graph = createGraph({ | ||
plugins: [{ type: 'history', key: 'history' }], | ||
data: { | ||
nodes: [ | ||
{ | ||
id: 'node-1', | ||
type: 'rect', | ||
style: { x: 50, y: 100 }, | ||
data: { | ||
aaa: { | ||
bbb: false, | ||
ccc: true, | ||
ddd: '1234', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
await graph.render(); | ||
|
||
expect(graph.getNodeData('node-1').style).toEqual({ x: 50, y: 100 }); | ||
expect(graph.getNodeData('node-1').data!.aaa).toEqual({ | ||
bbb: false, | ||
ccc: true, | ||
ddd: '1234', | ||
}); | ||
|
||
await graph.translateElementBy('node-1', [100, 100]); | ||
expect(graph.getNodeData('node-1').style).toEqual({ x: 150, y: 200, z: 0 }); | ||
expect(graph.getNodeData('node-1').data!.aaa).toEqual({ | ||
bbb: false, | ||
ccc: true, | ||
ddd: '1234', | ||
}); | ||
}); | ||
}); |
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