-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
568-refactor: Widget trainers (#604)
* refactor: 568 - change section titles * refactor: 568 - replace interface with type * refactor: 568 - move constants to constants.ts * refactor: 568 - change styles to modules * refactor: 568 - remove unnecessary styles * refactor: 568 - move test file to the ui folder * refactor: 568 - update tests * refactor: 568 - add style nesting
- Loading branch information
Showing
6 changed files
with
79 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const trainersTitle = { | ||
ru: 'Команда курса', | ||
en: 'Course Team', | ||
} as const; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.trainers-content { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
.trainers-list { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); | ||
gap: 32px; | ||
|
||
@include media-tablet-large { | ||
grid-template-columns: 1fr; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { Trainers } from './trainers'; | ||
import { MOCKED_ONE_TRAINER, MOCKED_SEVERAL_TRAINERS } from '@/shared/__tests__/constants'; | ||
|
||
describe('Trainers component', () => { | ||
const { name, role, bio, photo } = MOCKED_ONE_TRAINER[0]; | ||
const mockedTitle = { | ||
ru: 'Команда курса', | ||
en: 'Course Team', | ||
}; | ||
|
||
it('renders without crashing', () => { | ||
render(<Trainers trainers={MOCKED_ONE_TRAINER} />); | ||
const trainers = screen.getByTestId('trainers'); | ||
|
||
expect(trainers).toBeVisible(); | ||
}); | ||
|
||
it('renders the content correctly with mocked props', () => { | ||
render(<Trainers trainers={MOCKED_ONE_TRAINER} />); | ||
const titleElement = screen.getByTestId('widget-title'); | ||
const trainerNameElement = screen.getByText(name); | ||
const trainerTitleElement = screen.getByText(role); | ||
const trainerDescriptionElement = screen.getByText(bio); | ||
const trainerImageElement = screen.getByAltText(`${name} ${role}`); | ||
|
||
expect(titleElement).toBeVisible(); | ||
expect(trainerNameElement).toBeVisible(); | ||
expect(trainerTitleElement).toBeVisible(); | ||
expect(trainerDescriptionElement).toBeVisible(); | ||
expect(trainerImageElement).toBeVisible(); | ||
|
||
expect(titleElement).toHaveTextContent(mockedTitle.en); | ||
expect(trainerImageElement).toHaveAttribute('src', photo); | ||
}); | ||
|
||
it('renders the title content correctly with lang ru prop', () => { | ||
render(<Trainers trainers={MOCKED_ONE_TRAINER} lang="ru" />); | ||
const titleElement = screen.getByTestId('widget-title'); | ||
|
||
expect(titleElement).toHaveTextContent(mockedTitle.ru); | ||
}); | ||
|
||
it('renders all the trainers if passed several (8 in items)', () => { | ||
render(<Trainers trainers={MOCKED_SEVERAL_TRAINERS} />); | ||
const trainers = screen.getByTestId('trainers-list'); | ||
|
||
expect(trainers.childNodes).toHaveLength(8); | ||
}); | ||
}); |
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