-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cherry-pick #2279 - Move `exportLogs` and `logInit` to the `log` package so they could be reused in Enterprise - Remove `@deephaven/redux` and `@deephaven/jsapi-shim` dependencies from `LogExport.ts` - Serialize Maps in redux data - Unit tests for `getReduxDataString`
- Loading branch information
Showing
8 changed files
with
164 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,90 @@ | ||
import { getReduxDataString } from './LogExport'; | ||
|
||
describe('getReduxDataString', () => { | ||
it('should return a JSON string of the redux data', () => { | ||
const reduxData = { | ||
key1: 'value1', | ||
key2: 2, | ||
key3: true, | ||
}; | ||
const result = getReduxDataString(reduxData); | ||
const expected = JSON.stringify(reduxData, null, 2); | ||
expect(result).toBe(expected); | ||
}); | ||
|
||
it('should handle circular references', () => { | ||
const reduxData: Record<string, unknown> = { | ||
key1: 'value1', | ||
}; | ||
reduxData.key2 = reduxData; | ||
const result = getReduxDataString(reduxData); | ||
const expected = JSON.stringify( | ||
{ | ||
key1: 'value1', | ||
key2: 'Circular ref to root', | ||
}, | ||
null, | ||
2 | ||
); | ||
expect(result).toBe(expected); | ||
}); | ||
|
||
it('should handle BigInt values', () => { | ||
const reduxData = { | ||
key1: BigInt('12345678901234567890'), | ||
}; | ||
const result = getReduxDataString(reduxData); | ||
const expected = JSON.stringify( | ||
{ | ||
key1: '12345678901234567890', | ||
}, | ||
null, | ||
2 | ||
); | ||
expect(result).toBe(expected); | ||
}); | ||
|
||
it('should apply blacklist paths', () => { | ||
const reduxData = { | ||
key1: 'should be blacklisted', | ||
key2: { | ||
'key2.1': 'should also be blacklisted', | ||
}, | ||
key3: 'value', | ||
}; | ||
const result = getReduxDataString(reduxData, [ | ||
['key1'], | ||
['key2', 'key2.1'], | ||
]); | ||
const expected = JSON.stringify( | ||
{ | ||
key2: {}, | ||
key3: 'value', | ||
}, | ||
null, | ||
2 | ||
); | ||
expect(result).toBe(expected); | ||
}); | ||
|
||
it('should stringify Maps', () => { | ||
const reduxData = { | ||
key1: new Map([ | ||
['key1.1', 'value1.1'], | ||
['key1.2', 'value1.2'], | ||
]), | ||
}; | ||
const result = getReduxDataString(reduxData); | ||
const expected = JSON.stringify( | ||
{ | ||
key1: [ | ||
['key1.1', 'value1.1'], | ||
['key1.2', 'value1.2'], | ||
], | ||
}, | ||
null, | ||
2 | ||
); | ||
expect(result).toBe(expected); | ||
}); | ||
}); |
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
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
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