[go: up one dir, main page]

Skip to content

Commit

Permalink
Merge pull request #2 from TheTechCompany/feat/testing
Browse files Browse the repository at this point in the history
Feat/testing
  • Loading branch information
balbatross authored Mar 28, 2022
2 parents e42a914 + dd47977 commit 4b517bf
Show file tree
Hide file tree
Showing 7 changed files with 321 additions and 256 deletions.
15 changes: 15 additions & 0 deletions src/__tests__/AvatarList.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// __tests__/Kanban.test.ts
import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";

import { AvatarList } from "../components";

describe("AvatarList", () => {
test("check if avatar initials render", () => {
render(<AvatarList users={[{ name: "John Doe", color: "red" }]} />);

const element = screen.getByText("JD");
expect(element).toBeInTheDocument();
});
});
29 changes: 12 additions & 17 deletions src/__tests__/ColorDot.test.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
// __tests__/ColorDot.test.ts
import React from 'react'
import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { ColorDot } from "..";

import {render, fireEvent, waitFor, screen} from '@testing-library/react'
import { ColorDot } from '..'
describe("ColorDot", () => {
test("renders at specified size", () => {
render(<ColorDot size={5} color={"red"} />);

import '@testing-library/jest-dom'
const element = screen.getByRole("color-dot");

describe('ColorDot', () => {
test('renders at specified size', () => {
const { container } = render(<ColorDot size={5} color={'red'} />);

const element = container.querySelector('.hive-color-dot');

expect(element).toHaveStyle({
background: 'red',
width: '5px',
height: '5px'
});
})
})
expect(element.style.width).toBe("5px");
expect(element.style.height).toBe("5px");
});
});
29 changes: 29 additions & 0 deletions src/__tests__/GraphGrid.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// GraphGrid Tests
import React from "react";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { Box } from "grommet";

import { GraphGrid } from "../components";

describe("GraphGrid", () => {
test("TO DO - THIS TESTS NOTHING YET", () => {
render(
<GraphGrid
onLayoutChange={() => void 0}
layout={[
{
id: "1",
label: "label 1",
total: "total 1",
x: 0,
y: 0,
w: 2,
h: 2,
},
]}
children={(item: any) => <Box>{item.id}</Box>}
/>
);
});
});
18 changes: 10 additions & 8 deletions src/__tests__/Kanban.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import { Kanban } from '../components/Kanban/Kanban'
// __tests__/Kanban.test.ts
import React from "react";
import { Kanban } from "../components/Kanban/Kanban";
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";

describe('Kanban', () => {

test('Can add card', () => {

})
})
describe("KanBan", () => {
test("Tests to come when component is working", () => {
render(<Kanban columns={[]} />);
});
});
22 changes: 22 additions & 0 deletions src/components/AvatarList/AvatarList.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { ComponentStory, ComponentMeta } from "@storybook/react";

import { AvatarList } from "./index";

export default {
title: "Components/AvatarList",
component: AvatarList,
} as ComponentMeta<typeof AvatarList>;

const Template: ComponentStory<typeof AvatarList> = (args) => (
<AvatarList {...args} />
);

export const Primary = Template.bind({});
Primary.args = {
users: [
{ name: "John Doe", color: "red" },
{ name: "Bob Jones", color: "blue" },
],
size: 48,
};
29 changes: 13 additions & 16 deletions src/components/ColorDot/ColorDot.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import React, {
Component
} from 'react';

import React, { Component } from "react";

export interface ColorDotProps {
size: number,
color: string,
size: number;
color: string;
}

export const ColorDot : React.FC<ColorDotProps> = ({size, color}) => {

return (
<div
className="hive-color-dot"
export const ColorDot: React.FC<ColorDotProps> = ({ size, color }) => {
return (
<div
className="hive-color-dot"
role="color-dot"
style={{
marginRight: 8,
background: color,
borderRadius: size * 2,
height: size,
width: size
}}/>
);

}
width: size,
}}
/>
);
};
Loading

0 comments on commit 4b517bf

Please sign in to comment.