-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8054bd
commit d151b55
Showing
2 changed files
with
33 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import React from 'react'; | ||
import { render, cleanup, screen } from '@testing-library/react'; | ||
import { expect, it, afterEach, describe } from 'vitest'; | ||
import { expect, describe, it, afterEach } from 'vitest'; | ||
import { Home } from '@pages'; | ||
import createMatchMedia from '../helpers/createMatchMedia'; | ||
|
||
describe('Home Page', () => { | ||
afterEach(cleanup); | ||
// if tests are failing check this value vs value in Home.jsx | ||
const h1FontSize = '144px'; | ||
|
||
it('renders desktop', () => { | ||
it('renders with correct order of logoSection on mobile', () => { | ||
window.matchMedia = createMatchMedia(599); | ||
render(<Home />); | ||
const h1 = screen.getByTestId('testHomeH1'); | ||
const h1Styles = getComputedStyle(h1); | ||
const h1 = screen.getByTestId('testStack'); | ||
const children = Array.from(h1.children); | ||
|
||
expect(screen.getByTestId('testHomeSection')).toBeDefined(); | ||
expect(h1Styles.fontSize).toBe(h1FontSize); | ||
expect(children.length).toBe(3); | ||
expect(children[0].tagName.toLowerCase()).toBe('span'); | ||
expect(children[1].tagName.toLowerCase()).toBe('img'); | ||
expect(children[2].tagName.toLowerCase()).toBe('span'); | ||
}); | ||
|
||
it('renders mobile', () => { | ||
window.matchMedia = createMatchMedia(599); | ||
it('rrenders with correct order of logoSection on desktop', () => { | ||
window.matchMedia = createMatchMedia(1200); | ||
render(<Home />); | ||
const h1 = screen.getByTestId('testHomeH1'); | ||
const h1Styles = getComputedStyle(h1); | ||
const h1 = screen.getByTestId('testStack'); | ||
const children = Array.from(h1.children); | ||
|
||
expect(screen.getByTestId('testHomeSection')).toBeDefined(); | ||
expect(h1Styles.fontSize).not.toBe(h1FontSize); | ||
expect(children.length).toBe(2); | ||
expect(children[0].tagName.toLowerCase()).toBe('span'); | ||
expect(children[1].tagName.toLowerCase()).toBe('span'); | ||
}); | ||
}); |