Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #189 from smartive-education/feature/twin-unit-tes…
Browse files Browse the repository at this point in the history
…ting

Feature/twin unit testing
  • Loading branch information
webrooster authored Jun 26, 2023
2 parents a6cb577 + a55753b commit 6d82744
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
8 changes: 4 additions & 4 deletions __tests__/components/Like.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Like component', () => {

expect(screen.getByText('123 Likes')).toBeInTheDocument();

const svgFilled = container.querySelector('[class*=LikeButton__StyledHeartFilled]') as HTMLInputElement;
const svgFilled = container.querySelector('[class*=LikeButton__StyledHeartFilled]');
expect(svgFilled).toBeInTheDocument();

fireEvent.click(getByText('123 Likes'));
Expand All @@ -46,7 +46,7 @@ describe('Like component', () => {

expect(screen.getByText('122 Likes')).toBeInTheDocument();

const svgOutlined = container.querySelector('[class*=LikeButton__StyledHeartOutlined]') as HTMLInputElement;
const svgOutlined = container.querySelector('[class*=LikeButton__StyledHeartOutlined]');
expect(svgOutlined).toBeInTheDocument();
});

Expand All @@ -65,14 +65,14 @@ describe('Like component', () => {

expect(screen.getByText('321 Likes')).toBeInTheDocument();

const svgOutlined = container.querySelector('[class*=LikeButton__StyledHeartOutlined]') as HTMLInputElement;
const svgOutlined = container.querySelector('[class*=LikeButton__StyledHeartOutlined]');
expect(svgOutlined).toBeInTheDocument();

fireEvent.click(getByText('321 Likes'));

expect(screen.getByText('322 Likes')).toBeInTheDocument();

const svgFilled2 = container.querySelector('[class*=LikeButton__StyledHeartFilled]') as HTMLInputElement;
const svgFilled2 = container.querySelector('[class*=LikeButton__StyledHeartFilled]');
expect(svgFilled2).toBeInTheDocument();

expect(like).toHaveBeenCalled();
Expand Down
17 changes: 15 additions & 2 deletions __tests__/twin/Test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Test from './Test';

describe('Testing twin and styled components', () => {
it('finds a predefined sentence', () => {
const { container } = render(<Test text="i like styled components" />);
const text = screen.getByText(/i like styled components/i);
render(<Test text="i like styled components" />);
const text = screen.getByText(/i like styled components/);
expect(text).toHaveTextContent('i like styled components');
});

Expand All @@ -19,4 +19,17 @@ describe('Testing twin and styled components', () => {
const div = container.getElementsByTagName('div');
expect(div.length).toEqual(2);
});

it('finds specific classnames that get rendered with twin and styled components', () => {
const { container } = render(<Test text="i like styled components" />);

const StyledImportComponent = container.querySelector('[class*=Test__StyledImportComponent]');
expect(StyledImportComponent).toBeInTheDocument();

const TwImportComponent = container.querySelector('[class*=Test__TwImportComponent]');
expect(TwImportComponent).toBeInTheDocument();

const StyledDiv = container.querySelector('[class*=Test___StyledDiv]');
expect(StyledDiv).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Page({
fallbackUsers: QwackerUserResponse;
fallbackUserLoggedIn: User;
}) {
console.log(`Testing workflows 2 :-)`);
console.log(`Testing workflows 3 :-)`);
return (
<>
<NextSeo title={`${Content.seo.home.title}`} description={`${Content.seo.home.description}`} />
Expand Down

0 comments on commit 6d82744

Please sign in to comment.