-
Notifications
You must be signed in to change notification settings - Fork 46.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make serializable data for bridge in react-devtools
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
packages/react-devtools-shared/src/__tests__/backend/utils-test.js
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,43 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import {getSerializableData} from 'react-devtools-shared/src/backend/utils'; | ||
|
||
describe('backend/utils', () => { | ||
describe('getSerializableData', () => { | ||
it('should return null if data is null', () => { | ||
expect(getSerializableData(null)).toEqual(null); | ||
}); | ||
|
||
it('should return undefined if data is undefined', () => { | ||
expect(getSerializableData(undefined)).toEqual(undefined); | ||
}); | ||
|
||
it('should return string if data is string', () => { | ||
expect(getSerializableData('react')).toEqual('react'); | ||
}); | ||
|
||
it('should return number if data is number', () => { | ||
expect(getSerializableData(123)).toEqual(123); | ||
}); | ||
|
||
it('should return array object if data is array object', () => { | ||
expect(getSerializableData([{name: 'react'}])).toEqual([{name: 'react'}]); | ||
}); | ||
|
||
it('should return object if data is object', () => { | ||
expect(getSerializableData({name: 'react'})).toEqual({name: 'react'}); | ||
}); | ||
|
||
it('should return string with suffix n if data is BigInt', () => { | ||
// eslint-disable-next-line no-undef | ||
expect(getSerializableData(BigInt('123'))).toEqual('123n'); | ||
}); | ||
}); | ||
}); |
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