Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import JSONBigInt from 'json-bigint'
import { render, screen } from 'uiSrc/utils/test-utils'

import JsonPretty from './JsonPretty'
Expand All @@ -24,4 +25,16 @@ describe('JsonPretty', () => {

expect(screen.getByTestId('json-primitive-component')).toBeInTheDocument()
})

it('should render json primitive component with big number', () => {
const json = JSONBigInt({ useNativeBigInt: true }).parse('1234567890123456789012345678901234567890')
render(<JsonPretty data={json} />)
expect(screen.getByTestId('json-primitive-component')).toBeInTheDocument()
})

it('should render json primitive component with big float', () => {
const json = JSONBigInt({ useNativeBigInt: false }).parse('1234567890123456789012345678901234567890.1234567890123456789012345678901234567890')
render(<JsonPretty data={json} />)
expect(screen.getByTestId('json-primitive-component')).toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { isArray, isObject } from 'uiSrc/components/json-viewer/utils'
import { IDefaultProps } from 'uiSrc/components/json-viewer/interfaces'

const JsonPretty = ({ data, ...props }: IDefaultProps) => {
if (data?._isBigNumber) {
return <JsonPrimitive data={data} {...props} />
}

if (isArray(data)) {
return <JsonArray data={data} {...props} />
}
Expand Down
2 changes: 1 addition & 1 deletion redisinsight/ui/src/utils/formatters/valueFormatters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const bufferToJSON = (
reply: RedisResponseBuffer,
props: FormattingProps
): { value: JSX.Element | string, isValid: boolean } =>
JSONViewer({ value: bufferToUTF8(reply), ...props })
JSONViewer({ value: bufferToUTF8(reply), useNativeBigInt: false, ...props })

const formattingBuffer = (
reply: RedisResponseBuffer,
Expand Down