Skip to content

Commit

Permalink
Update tests for changed widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
abigailalexander committed Mar 1, 2024
1 parent 903c5cf commit 9fc8a58
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
15 changes: 10 additions & 5 deletions src/ui/widgets/Arc/arc.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ describe("<ArcComponent />", (): void => {
expect(svg.props.viewBox).toEqual("0 0 100 100");

const pathArray = svg.children as Array<ReactTestRendererJSON>;
// Default doesn't fill, expect just border paths of arc
expect(pathArray.length).toEqual(1);
console.log(pathArray);

Check warning on line 25 in src/ui/widgets/Arc/arc.test.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement
// Default fills, expect border path and fill of arc
expect(pathArray.length).toEqual(2);
// Filled arc
expect(pathArray[0].props.d).toEqual("M 100 50\nA 50 50 0 0 1 50 100");
expect(pathArray[0].props.fill).toEqual("transparent");
expect(pathArray[0].props.stroke).toEqual("rgba(0,1,255,255)");
expect(pathArray[0].props.d).toEqual("M 50 50\nL 100 50\nA 50 50 0 0 1 50 100\nZ");

Check failure on line 29 in src/ui/widgets/Arc/arc.test.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `"M·50·50\nL·100·50\nA·50·50·0·0·1·50·100\nZ"` with `⏎······"M·50·50\nL·100·50\nA·50·50·0·0·1·50·100\nZ"⏎····`
expect(pathArray[0].props.fill).toEqual("rgba(200,1,60,255)");
expect(pathArray[0].props.stroke).toEqual("rgba(200,1,60,255)");
// BOrder
expect(pathArray[1].props.d).toEqual("M 100 50\nA 50 50 0 0 1 50 100");
expect(pathArray[1].props.fill).toEqual("transparent");
expect(pathArray[1].props.stroke).toEqual("rgba(0,1,255,255)");
});

test("create arc of angle > 180 degrees", (): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/BoolButton/boolButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("<BoolButton />", (): void => {
expect(button.style.height).toEqual("50px");
expect(button.style.width).toEqual("100px");
expect(button.style.backgroundColor).toEqual("rgb(200, 200, 200)");
expect(button.style.borderRadius).toEqual("50%");
expect(button.style.borderRadius).toEqual("");
});

test("it renders a button with led and overwrites default values", (): void => {
Expand Down
11 changes: 4 additions & 7 deletions src/ui/widgets/ByteMonitor/byteMonitor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ describe("<ByteMonitorComponent />", (): void => {

const byteMonitor = ByteMonitorRenderer(byteMonitorProps);
const bits = byteMonitor.children as Array<ReactTestRendererJSON>;
expect(bits.length).toEqual(16);
expect(bits.length).toEqual(8);

expect(bits[0].props.style.marginRight).toEqual("-2px");
expect(bits[1].props.style.borderWidth).toEqual("2px");
expect(bits[5].props.style.backgroundColor).toEqual("rgba(0,100,0,255)");
expect(bits[10].props.style.backgroundImage).toEqual(
"radial-gradient(circle at top left, white, rgba(0,100,0,255)), radial-gradient(circle at top left, black,white)"
);
expect(bits[15].props.style.borderRadius).toEqual("50%");
expect(bits[5].props.style.backgroundColor).toEqual("rgba(0,255,0,255)");
expect(bits[7].props.style.borderRadius).toEqual("50%");
});
test("overwrite bytemonitor defautl values", (): void => {
test("overwrite bytemonitor default values", (): void => {
const byteMonitorProps = {
value: new DType({ doubleValue: 2 }),
height: 50,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/Line/line.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("<LineComponent />", (): void => {
const lines = svg.children as Array<ReactTestRendererJSON>;

expect(lines[0].props.stroke).toEqual("rgba(0,255,255,255)");
expect(lines[0].props.strokeWidth).toEqual(1);
expect(lines[0].props.strokeWidth).toEqual(3);
expect(lines[0].props.transform).toEqual("rotation(0,0,0)");
expect(lines[0].props.points).toEqual("1,10 15,20 4,15 ");
});
Expand Down
7 changes: 5 additions & 2 deletions src/ui/widgets/Polygon/polygon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("<PolygonComponent />", (): void => {
expect(polygons[0].props.strokeWidth).toEqual(2);
});

test("no points props, component doesn't render", (): void => {
test("no points props, component renders without points", (): void => {
const polygonProps = {
height: 10,
width: 20,
Expand All @@ -49,6 +49,9 @@ describe("<PolygonComponent />", (): void => {
};

const svg = PolygonRenderer(polygonProps);
expect(svg).toBeNull();
const polygons = svg.children as Array<ReactTestRendererJSON>;
expect(polygons.length).toEqual(1);
expect(polygons[0].props.points).toEqual("");

});
});

0 comments on commit 9fc8a58

Please sign in to comment.