-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: manage 'no tracking details' scenario
- Loading branch information
1 parent
5e2c9ef
commit d7fb240
Showing
8 changed files
with
275 additions
and
87 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,86 @@ | ||
import { render } from '@testing-library/react' | ||
import { Steps } from './Steps' | ||
|
||
describe('Steps', () => { | ||
it('Should be rendered', () => { | ||
const { container } = render( | ||
<Steps | ||
steps={[{ label: 'Step 1' }, { label: 'Step 2' }, { label: 'Step 3' }]} | ||
/> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
it('Should render as many `li` as many steps are provided', () => { | ||
const { getByRole } = render( | ||
<Steps | ||
steps={[{ label: 'Step 1' }, { label: 'Step 2' }, { label: 'Step 3' }]} | ||
/> | ||
) | ||
|
||
expect(getByRole('list').children.length).toEqual(3) | ||
expect(getByRole('list').children[0].textContent).toEqual('Step 1') | ||
expect(getByRole('list').children[1].textContent).toEqual('Step 2') | ||
expect(getByRole('list').children[2].textContent).toEqual('Step 3') | ||
}) | ||
|
||
it('Should highlight all non "active" steps', () => { | ||
const { getByText } = render( | ||
<Steps | ||
steps={[{ label: 'Step 1' }, { label: 'Step 2' }, { label: 'Step 3' }]} | ||
/> | ||
) | ||
|
||
expect(getByText('Step 1').previousSibling).toHaveClass('bg-gray-100') | ||
expect(getByText('Step 2').previousSibling).toHaveClass('bg-gray-100') | ||
expect(getByText('Step 3').previousSibling).toHaveClass('bg-gray-100') | ||
}) | ||
|
||
it('Should highlight the "active" steps', () => { | ||
const { getByText } = render( | ||
<Steps | ||
steps={[ | ||
{ label: 'Step 1', active: true }, | ||
{ label: 'Step 2', active: true }, | ||
{ label: 'Step 3' } | ||
]} | ||
/> | ||
) | ||
|
||
expect(getByText('Step 1').previousSibling).toHaveClass('bg-primary') | ||
expect(getByText('Step 1').previousSibling).not.toHaveClass( | ||
'after:bg-white' | ||
) | ||
expect(getByText('Step 2').previousSibling).toHaveClass( | ||
'bg-primary after:bg-white' | ||
) | ||
expect(getByText('Step 3').previousSibling).toHaveClass('bg-gray-100') | ||
expect(getByText('Step 3').previousSibling).not.toHaveClass( | ||
'after:bg-white' | ||
) | ||
}) | ||
|
||
it('Should mark as "active" all previous step from the latest "active"', () => { | ||
const { getByText } = render( | ||
<Steps | ||
steps={[ | ||
{ label: 'Step 1' }, | ||
{ label: 'Step 2', active: true }, | ||
{ label: 'Step 3' } | ||
]} | ||
/> | ||
) | ||
|
||
expect(getByText('Step 1').previousSibling).toHaveClass('bg-primary') | ||
expect(getByText('Step 1').previousSibling).not.toHaveClass( | ||
'after:bg-white' | ||
) | ||
expect(getByText('Step 2').previousSibling).toHaveClass( | ||
'bg-primary after:bg-white' | ||
) | ||
expect(getByText('Step 3').previousSibling).toHaveClass('bg-gray-100') | ||
expect(getByText('Step 3').previousSibling).not.toHaveClass( | ||
'after:bg-white' | ||
) | ||
}) | ||
}) |
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
46 changes: 46 additions & 0 deletions
46
packages/app-elements/src/ui/atoms/__snapshots__/Steps.test.tsx.snap
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,46 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Steps > Should be rendered 1`] = ` | ||
<div> | ||
<ul | ||
class="flex justify-between text-xs w-full items-center rounded h-2 mb-8 bg-gradient-to-r from-gray-100 from-50% to-primary to-50% bg-[length:200%]" | ||
> | ||
<li | ||
class="relative text-gray-300 font-semibold" | ||
> | ||
<div | ||
class="w-6 h-6 rounded-full flex justify-center items-center bg-gray-100" | ||
/> | ||
<div | ||
class="absolute whitespace-nowrap mt-1 translate-x-0" | ||
> | ||
Step 1 | ||
</div> | ||
</li> | ||
<li | ||
class="relative text-gray-300 font-semibold" | ||
> | ||
<div | ||
class="w-6 h-6 rounded-full flex justify-center items-center bg-gray-100" | ||
/> | ||
<div | ||
class="absolute whitespace-nowrap mt-1 translate-x-[calc(-50%+12px)]" | ||
> | ||
Step 2 | ||
</div> | ||
</li> | ||
<li | ||
class="relative text-gray-300 font-semibold" | ||
> | ||
<div | ||
class="w-6 h-6 rounded-full flex justify-center items-center bg-gray-100" | ||
/> | ||
<div | ||
class="absolute whitespace-nowrap mt-1 right-0" | ||
> | ||
Step 3 | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
`; |
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
Oops, something went wrong.