-
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.
* starting RTL tests * fix provider wrap * first integration test * add shell
- Loading branch information
1 parent
a4be3ed
commit 8f453b7
Showing
15 changed files
with
509 additions
and
191 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,11 @@ | ||
name: Run Jest Client Tests | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup-node | ||
- run: | | ||
cd client | ||
pnpm test | ||
shell: bash |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
45 changes: 45 additions & 0 deletions
45
client/src/components/utilities/ColoredTypography.spec.tsx
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,45 @@ | ||
import ColoredTypography from "./ColoredTypography" | ||
import { render, getRandomGameState, getCurrentColorMode } from '../../../tests/utilities/render' | ||
import { ActionAttributes, Actions, InfluenceAttributes, Influences } from "../../shared/types/game" | ||
|
||
describe('ColoredTypography', () => { | ||
it('should render a single element when no matches', async () => { | ||
const { findByText } = render(<ColoredTypography>text to color</ColoredTypography>) | ||
|
||
await findByText('text to color') | ||
}) | ||
|
||
it('should render a single element when no matches', async () => { | ||
const gameState = getRandomGameState() | ||
|
||
gameState.players[0].name = 'David' | ||
gameState.players[1].name = 'Dаvid' | ||
|
||
const { findByText } = render( | ||
<> | ||
<ColoredTypography>David is trying to use Coup on Dаvid</ColoredTypography> | ||
<ColoredTypography>someone has lost their Contessa</ColoredTypography> | ||
</>, | ||
{ gameState } | ||
) | ||
|
||
const colorMode = await getCurrentColorMode() | ||
|
||
const expectedSegments = [ | ||
{ text: 'David', color: gameState.players[0].color }, | ||
{ text: ' is trying to use ' }, | ||
{ text: 'Coup', color: ActionAttributes[Actions.Coup].color[colorMode] }, | ||
{ text: ' on ' }, | ||
{ text: 'Dаvid', color: gameState.players[1].color }, | ||
{ text: 'someone has lost their ' }, | ||
{ text: 'Contessa', color: InfluenceAttributes[Influences.Contessa].color[colorMode] } | ||
] | ||
|
||
for (const expectedSegment of expectedSegments) { | ||
const segment = await findByText(expectedSegment.text, { trim: false }) | ||
if (expectedSegment.color) { | ||
expect(segment).toHaveStyle({ color: expectedSegment.color }) | ||
} | ||
} | ||
}) | ||
}) |
Oops, something went wrong.