Skip to content

Commit

Permalink
added unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
johncalesp committed Mar 22, 2023
1 parent e36f525 commit 3d1786b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
1 change: 0 additions & 1 deletion skyline-vscode/react-ui/src/sections/Habitat.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Card from "react-bootstrap/Card";
import { HabitatScatterGraph } from "../components/ScatterGraph";

export default function Habitat({ habitatData }) {
console.log(habitatData);
const habitatIsDemo = habitatData.find(
(item) => item[0] === "demo" && item[1] === 1
);
Expand Down
23 changes: 23 additions & 0 deletions skyline-vscode/react-ui/src/sections/Habitat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ const data = [
["RTX4000", 20.2342],
];

const noHabitatData = [
["source", 22.029312],
["P100",14.069682],
["P4000", 127.268085], // 27.268085
["RTX2070", 16.088268],
["RTX2080Ti", 11.826558],
["T4", 22.029312],
["V100", 10.182922],
["A100", 10.068596],
["RTX3090", 9.841998],
["A40", 11.558072],
["A4000", 14.67059],
["RTX4000", 20.2342],
["demo",1]
]

beforeEach(() => {
delete window.ResizeObserver;
window.ResizeObserver = jest.fn().mockImplementation(() => ({
Expand Down Expand Up @@ -61,3 +77,10 @@ test("Shows graph when habitat data is present", () => {
expect(container.querySelector('.recharts-responsive-container')).toBeTruthy(); // eslint-disable-line

});

test("no habitat data received from backend", ()=>{
// ARRANGE
const { container } = render(<Habitat habitatData={noHabitatData}/>);
// ASSERT
expect(screen.getByText(/the local gpu is not supported by habitat/i)).toBeTruthy();
})
23 changes: 23 additions & 0 deletions skyline-vscode/react-ui/src/sections/ProviderPanel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ const data = [
["RTX4000", 20.2342],
];

const noHabitatData = [
["source", 22.029312],
["P100",14.069682],
["P4000", 127.268085], // 27.268085
["RTX2070", 16.088268],
["RTX2080Ti", 11.826558],
["T4", 22.029312],
["V100", 10.182922],
["A100", 10.068596],
["RTX3090", 9.841998],
["A40", 11.558072],
["A4000", 14.67059],
["RTX4000", 20.2342],
["demo",1]
];

beforeEach(() => {
delete window.ResizeObserver;
window.ResizeObserver = jest.fn().mockImplementation(() => ({
Expand Down Expand Up @@ -62,3 +78,10 @@ test("Shows a scatter chart", () => {
).toBeTruthy();
expect(screen.getByText(/select a configuration/i)).toBeTruthy();
});

test("no habitat data received from backend", ()=>{
// ARRANGE
const { container } = render(<ProviderPanel numIterations={numIterations} habitatData={noHabitatData} />);
// ASSERT
expect(screen.getByText(/currently showing a demo data because local gpu is not supported by habitat/i)).toBeTruthy();
})

0 comments on commit 3d1786b

Please sign in to comment.