-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(General): ✅ Increment code coverage
- Loading branch information
Showing
31 changed files
with
763 additions
and
199 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/core/components/HighlightValueCell/__tests__/HighLightValueCell.spec.tsx
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,45 @@ | ||
import React from 'react'; | ||
|
||
import { render } from '@testing-library/react'; | ||
|
||
import { VarColors } from '@config/colors'; | ||
|
||
import HighlightValueCell from './../index'; | ||
|
||
describe('HighlightValueCell', () => { | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('should render without highlighting when value is not updated', () => { | ||
const data = { id: 1, name: 'Test' }; | ||
const value = 42; | ||
const format = jest.fn((val) => val); | ||
|
||
const useRefSpy = jest.spyOn(React, 'useRef'); | ||
useRefSpy.mockReturnValue({ current: value }); | ||
|
||
const { getByText, queryByTestId } = render(<HighlightValueCell data={data} value={value} format={format} />); | ||
|
||
expect(getByText('42')).toBeInTheDocument(); | ||
expect(format).toHaveBeenCalledWith(value); | ||
expect(queryByTestId('highlighted-value')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render with highlighting when value is updated', () => { | ||
const data = { id: 1, name: 'Test' }; | ||
const value = 42; | ||
const newValue = 50; | ||
const format = jest.fn((val) => val); | ||
|
||
const useRefSpy = jest.spyOn(React, 'useRef'); | ||
useRefSpy.mockReturnValue({ current: value }); | ||
|
||
const { getByText, getByTestId } = render(<HighlightValueCell data={data} value={newValue} format={format} />); | ||
|
||
expect(getByText('50')).toBeInTheDocument(); | ||
expect(format).toHaveBeenCalledWith(newValue); | ||
expect(getByTestId('highlighted-value')).toBeInTheDocument(); | ||
expect(getByTestId('highlighted-value')).toHaveStyle(`color: ${VarColors.Green500}; font-weight: 900;`); | ||
}); | ||
}); |
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,47 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import { Wrapper } from '@core/components/Wrapper'; | ||
|
||
import LinkCell from '../index'; | ||
|
||
describe('LinkCell', () => { | ||
const data = { id: 1, name: 'Test' }; | ||
|
||
it('should render a disabled cell with Truncate for non-empty value', () => { | ||
render(<LinkCell data={data} value="Long text" isDisabled={true} link="/some-link" />); | ||
const truncateElement = screen.getByText('Long text'); | ||
expect(truncateElement).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render a non-disabled cell with Link for non-empty value', () => { | ||
render( | ||
<Wrapper> | ||
<LinkCell data={data} value="Long text" link="/some-link" /> | ||
</Wrapper> | ||
); | ||
const linkElement = screen.getByRole('link'); | ||
expect(linkElement).toHaveAttribute('href', '#/some-link'); | ||
}); | ||
|
||
it('should render an empty cell', () => { | ||
render(<LinkCell data={data} value="" link="/some-link" />); | ||
const emptyElement = screen.getByText("''"); | ||
expect(emptyElement).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render a non-disabled cell with fitContent', () => { | ||
render( | ||
<Wrapper> | ||
<LinkCell data={data} value="Long text" link="/some-link" fitContent={true} /> | ||
</Wrapper> | ||
); | ||
const textElement = screen.getByText('Long text'); | ||
expect(textElement).toBeInTheDocument(); | ||
}); | ||
|
||
it('should handle non-string values', () => { | ||
render(<LinkCell data={data} value={undefined} link="/some-link" />); | ||
const emptyElement = screen.getByText("''"); | ||
expect(emptyElement).toBeInTheDocument(); | ||
}); | ||
}); |
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,55 @@ | ||
import { VarColors } from '@config/colors'; | ||
import { DEFAULT_FONT_VAR } from '@config/config'; | ||
|
||
import { Themes } from './SkSankeyChart.interfaces'; | ||
|
||
// Constants | ||
export const DEFAULT_SANKEY_CHART_FLOW_VALUE = 0.000001; | ||
export const DEFAULT_SANKEY_CHART_HEIGHT = '350px'; | ||
|
||
// Themes | ||
const commonStyle = { | ||
fontSize: 14, | ||
fontFamily: DEFAULT_FONT_VAR, | ||
tooltip: { container: { color: VarColors.Black900 } } | ||
}; | ||
|
||
export const themeStyle: Themes = { | ||
dark: { | ||
...commonStyle, | ||
labelTextColor: VarColors.White | ||
}, | ||
|
||
light: { | ||
...commonStyle, | ||
labelTextColor: VarColors.Black900 | ||
} | ||
}; | ||
|
||
//Filters | ||
export const sankeyMetricOptions = [ | ||
{ id: 'none', name: 'Display only relationships' }, | ||
{ id: 'byterate', name: 'Compare avg. byterate (last hour)' } | ||
]; | ||
|
||
export const ServiceClientResourceOptions: { name: string; id: 'client' | 'clientSite' }[] = [ | ||
{ | ||
name: 'Client sites', | ||
id: 'clientSite' | ||
}, | ||
{ | ||
name: 'Client processes', | ||
id: 'client' | ||
} | ||
]; | ||
|
||
export const ServiceServerResourceOptions: { name: string; id: 'server' | 'serverSite' }[] = [ | ||
{ | ||
name: 'Server sites', | ||
id: 'serverSite' | ||
}, | ||
{ | ||
name: 'Server processes', | ||
id: 'server' | ||
} | ||
]; |
32 changes: 32 additions & 0 deletions
32
src/core/components/SKSanckeyChart/SkSankeyChart.interfaces.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,32 @@ | ||
import { VarColors } from '@config/colors'; | ||
|
||
export interface ThemesProps { | ||
labelTextColor: VarColors; | ||
fontFamily: string; | ||
fontSize: number; | ||
tooltip: { container: { color: string } }; | ||
} | ||
|
||
export interface Themes { | ||
[key: string]: ThemesProps; | ||
} | ||
|
||
export interface SkSankeyChartNode { | ||
id: string; | ||
nodeColor?: string; | ||
} | ||
|
||
interface SkSankeyChartLink { | ||
source: string; | ||
target: string; | ||
value: number; | ||
} | ||
|
||
export interface SkSankeyChartProps { | ||
nodes: SkSankeyChartNode[]; | ||
links: SkSankeyChartLink[]; | ||
} | ||
|
||
export interface SankeyFilterValues { | ||
[key: string]: string | undefined; | ||
} |
Oops, something went wrong.