-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: improve RefStateEditor.set performance (#221)
- Loading branch information
1 parent
5ce3a00
commit 112ecb7
Showing
2 changed files
with
28 additions
and
7 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/devtools-kit/src/core/component/state/__test__/editor.test.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,24 @@ | ||
import { RefStateEditor } from '../editor' | ||
|
||
describe('editor: RefStateEditor', () => { | ||
const editor = new RefStateEditor() | ||
|
||
// eslint-disable-next-line test/consistent-test-it | ||
test.each([ | ||
// Add new key. | ||
{ refValue: { foo: 'bar' }, newValue: { foo: 'bar', bar: 'baz' } }, | ||
// Add new key and modify origin value. | ||
{ refValue: { foo: 'bar' }, newValue: { foo: 'barr', bar: 'baz' } }, | ||
// Modify origin value. | ||
{ refValue: { foo: 'bar' }, newValue: { foo: 'barr' } }, | ||
// Remove key. | ||
{ refValue: { foo: 'bar' }, newValue: {} }, | ||
// Remove key and modify origin value. | ||
{ refValue: { foo: 'bar' }, newValue: { foo: 'barr' } }, | ||
// Remove key and add new key. | ||
{ refValue: { foo: 'bar' }, newValue: { bar: 'baz' } }, | ||
])('$refValue can be modified to $newValue by RefStateEditor.set', ({ refValue, newValue }) => { | ||
editor.set(refValue as any, newValue) | ||
expect(refValue).toEqual(newValue) | ||
}) | ||
}) |
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