-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Add 2x3 grid support for Matching Pairs component if it has eq…
…ual or less than 6 sections (#657) * refactor: Update scss-watch command to be scss:watch * feat: Add classNames utility function This commit adds a utility function called `classNames` to the `util` directory of the frontend code. The `classNames` function takes in multiple string arguments and returns a single string with the classes joined together, separated by a space. It also filters out any falsy values before joining the classes. The commit also includes a test suite for the `classNames` function, covering scenarios where multiple classes are joined, falsy values are filtered, and empty strings and no arguments are provided. * feat: Update MatchingPairs column amount behavior - Add condition to determine column count based on the number of sections in the code. - Update CSS styles for the playing board based on column count. - Remove unnecessary white spaces and newlines in the code. * story: Add MatchingPairs story with default props and two columns support This commit adds the MatchingPairs component with its default props and support for displaying two columns of sections. The component automatically adjusts the number of columns based on the number of sections provided. If there are six or less sections, two columns are displayed. If there are more than six sections, four columns are displayed. The component is also displayed in fullscreen mode. * test: Add tests for the MatchingPairs component - Added tests for the MatchingPairs component to ensure it properly displays two columns when the sections length is less than or equal to 6, and four columns when the sections length is greater than 6. The tests use a mock PlayCard component and check for the presence or absence of specific CSS classes on the playing board. * refactor: MatchingPairs displays 3 columns instead of 2 when sections <= 6 * config: Add storybook script and update permissions on test-front-ci * fix: Fix classes & story by actually showing 3 columns instead of 2
- Loading branch information
1 parent
7276f39
commit 10962ef
Showing
8 changed files
with
278 additions
and
42 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import MatchingPairs from './MatchingPairs'; | ||
|
||
jest.mock("../PlayButton/PlayCard", () => (props) => ( | ||
<div data-testid="play-card" {...props} /> | ||
)); | ||
|
||
describe('MatchingPairs Component', () => { | ||
|
||
const baseProps = { | ||
playSection: jest.fn(), | ||
playerIndex: 0, | ||
finishedPlaying: jest.fn(), | ||
stopAudioAfter: jest.fn(), | ||
submitResult: jest.fn(), | ||
}; | ||
|
||
it('displays three columns when sections length is less than or equal to 6', () => { | ||
const sections = new Array(6).fill({}).map((_, index) => ({ id: index })); | ||
const { container } = render(<MatchingPairs {...baseProps} sections={sections} />); | ||
expect(container.querySelector('.playing-board--three-columns')).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays four columns when sections length is greater than 6', () => { | ||
const sections = new Array(7).fill({}).map((_, index) => ({ id: index })); | ||
const { container } = render(<MatchingPairs {...baseProps} sections={sections} />); | ||
expect(container.querySelector('.playing-board--two-columns')).not.toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.