-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from sharmalab/tests-add
Add Chart Tests
- Loading branch information
Showing
18 changed files
with
373 additions
and
11 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 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
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
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,41 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import BarChart from '../source/components/VisualTools/Chart/BarChart'; | ||
|
||
const mockData = [ | ||
{ category: 'A' }, | ||
{ category: 'B' }, | ||
{ category: 'A' }, | ||
{ category: 'C' }, | ||
{ category: 'B' }, | ||
{ category: 'A' }, | ||
]; | ||
|
||
const mockFields = { | ||
x: 'category', | ||
isList: false, | ||
}; | ||
|
||
const mockLayout = { width: 500, currentCols: 1 }; | ||
const mockFilters = []; | ||
const mockTitle = 'Test Bar Chart'; | ||
const mockId = 'test-bar-chart'; | ||
|
||
describe('BarChart Vis Component', () => { | ||
it('renders', () => { | ||
render( | ||
<BarChart | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={[]} | ||
layout={mockLayout} | ||
/> | ||
); | ||
const chartElement = screen.getByRole('figure', { hidden: true }); | ||
expect(chartElement).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import DensityChart from '../source/components/VisualTools/Chart/DensityChart'; | ||
|
||
const mockData = [ | ||
{ x: 10, y: 20 }, | ||
{ x: 15, y: 25 }, | ||
{ x: 20, y: 30 }, | ||
]; | ||
|
||
const mockFields = { x: 'x', y: 'y' }; | ||
const mockLayout = { width: 500, currentCols: 1 }; | ||
const mockFilters = []; | ||
const mockTitle = 'Test Density Chart'; | ||
const mockFilterAdded = []; | ||
const mockId = 'test-density-chart'; | ||
|
||
describe('DensityChart Component', () => { | ||
it('renders', () => { | ||
render( | ||
<DensityChart | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={mockFilterAdded} | ||
layout={mockLayout} | ||
/> | ||
); | ||
expect(document.getElementById(mockId)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Heatmap from '../source/components/VisualTools/Chart/Heatmap'; | ||
import '@testing-library/jest-dom'; | ||
|
||
const mockData = [ | ||
{ x: 'A', y: '1', z: 10 }, | ||
{ x: 'B', y: '1', z: 20 }, | ||
{ x: 'A', y: '2', z: 30 }, | ||
]; | ||
|
||
const mockFields = { | ||
x: 'x', | ||
y: 'y', | ||
z: 'z', | ||
}; | ||
|
||
const mockFilters = []; | ||
const mockFilterAdded = []; | ||
const mockTitle = 'Test Heatmap Chart'; | ||
const mockId = 'test-heatmap-chart'; | ||
const mockLayout = { | ||
width: 500, | ||
currentCols: 2, | ||
}; | ||
|
||
test('renders without crashing', () => { | ||
render( | ||
<Heatmap | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={mockFilterAdded} | ||
layout={mockLayout} | ||
/> | ||
); | ||
expect(document.getElementById(mockId)).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import Histogram from '../source/components/VisualTools/Chart/Histogram'; | ||
|
||
const mockData = [ | ||
{ category: 10 }, | ||
{ category: 11 }, | ||
{ category: 12 }, | ||
{ category: 12 }, | ||
{ category: 15 }, | ||
{ category: 21 }, | ||
]; | ||
|
||
const mockFields = { | ||
x: 'category' | ||
}; | ||
|
||
const mockLayout = { width: 500, currentCols: 1 }; | ||
const mockFilters = []; | ||
const mockTitle = 'Test Histogram Chart'; | ||
const mockId = 'test-histogram-chart'; | ||
|
||
describe('Histogram Vis Component', () => { | ||
it('renders', () => { | ||
render( | ||
<Histogram | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={[]} | ||
layout={mockLayout} | ||
binsCount={3} | ||
/> | ||
); | ||
const chartElement = screen.getByRole('figure', { hidden: true }); | ||
expect(chartElement).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import HorizontalBarChart from '../source/components/VisualTools/Chart/HorizontalBarChart'; | ||
|
||
const mockData = [ | ||
{ category: 'A' }, | ||
{ category: 'B' }, | ||
{ category: 'A' }, | ||
{ category: 'C' }, | ||
{ category: 'B' }, | ||
{ category: 'A' }, | ||
]; | ||
|
||
const mockFields = { | ||
x: 'category', | ||
isList: false, | ||
}; | ||
|
||
const mockLayout = { width: 500, currentCols: 1 }; | ||
const mockFilters = []; | ||
const mockTitle = 'Test Horiz Bar Chart'; | ||
const mockId = 'test-horiz-bar-chart'; | ||
|
||
describe('HorizontalBarChart Vis Component', () => { | ||
it('renders', () => { | ||
render( | ||
<HorizontalBarChart | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={[]} | ||
layout={mockLayout} | ||
/> | ||
); | ||
const chartElement = screen.getByRole('figure', { hidden: true }); | ||
expect(chartElement).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import KMCurve from '../source/components/VisualTools/Chart/KMCurve'; | ||
|
||
const mockData = [ | ||
{ collapsed_stage: 'stage_x/NR', time: 1, event: 'event', group: 'group1' }, | ||
{ collapsed_stage: 'stage_x/NR', time: 2, event: 'event', group: 'group1' }, | ||
{ collapsed_stage: 'stage_x/NR', time: 3, event: 'censor', group: 'group1' }, | ||
{ collapsed_stage: 'stage_x/NR', time: 1, event: 'event', group: 'group2' }, | ||
{ collapsed_stage: 'stage_x/NR', time: 2, event: 'censor', group: 'group2' }, | ||
]; | ||
|
||
const mockFields = { | ||
x: 'group', | ||
time: { field: 'time' }, | ||
event: { field: 'event', eventValue: 'event', censoredValue: 'censor' }, | ||
group: { field: 'group' }, | ||
}; | ||
|
||
const mockLayout = { width: 500, currentCols: 1 }; | ||
const mockFilters = []; | ||
const mockTitle = 'Test KMCurve Chart'; | ||
const mockId = 'test-km-curve-chart'; | ||
|
||
describe('KMCurve Vis Component', () => { | ||
it('renders', () => { | ||
render( | ||
<KMCurve | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={[]} | ||
layout={mockLayout} | ||
/> | ||
); | ||
const chartElement = screen.getByRole('figure', { hidden: true }); | ||
expect(chartElement).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import ParallelCoordinates from '../source/components/VisualTools/Chart/ParallelCoordinates'; | ||
|
||
const mockData = [ | ||
{ dimension1: 10, dimension2: 20, dimension3: 30 }, | ||
{ dimension1: 15, dimension2: 25, dimension3: 35 }, | ||
{ dimension1: 20, dimension2: 30, dimension3: 40 }, | ||
{ dimension1: 25, dimension2: 35, dimension3: 45 }, | ||
{ dimension1: 30, dimension2: 40, dimension3: 50 }, | ||
]; | ||
|
||
const mockFields = { | ||
y: ['dimension1', 'dimension2', 'dimension3'], | ||
}; | ||
|
||
const mockLayout = { width: 500, currentCols: 1 }; | ||
const mockFilters = []; | ||
const mockTitle = 'Test Parallel Coordinates Chart'; | ||
const mockId = 'test-parallel-coords-chart'; | ||
|
||
describe('ParallelCoordinates Vis Component', () => { | ||
it('renders', () => { | ||
render( | ||
<ParallelCoordinates | ||
data={mockData} | ||
fields={mockFields} | ||
id={mockId} | ||
title={mockTitle} | ||
filterData={mockData} | ||
filters={mockFilters} | ||
filterAdded={[]} | ||
layout={mockLayout} | ||
/> | ||
); | ||
const chartElement = screen.getByRole('figure', { hidden: true }); | ||
expect(chartElement).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.