-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial user search toolbar * Searchbar component * tests * fixes * tests
- Loading branch information
Showing
11 changed files
with
221 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ion-searchbar.ls-searchbar { | ||
--border-radius: 0.25rem; | ||
} | ||
|
||
ion-toolbar.ls-toolbar-searchbar { | ||
--padding-start: 9px; | ||
--padding-end: 9px; | ||
} |
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,35 @@ | ||
import { ComponentPropsWithoutRef } from 'react'; | ||
import { IonSearchbar } from '@ionic/react'; | ||
import classNames from 'classnames'; | ||
|
||
import './Searchbar.scss'; | ||
import { PropsWithTestId } from '../types'; | ||
|
||
/** | ||
* Properties for the `Searchbar` component. | ||
* @see {@link PropsWithTestId} | ||
* @see {@link IonSearchbar} | ||
*/ | ||
interface SearchbarProps extends PropsWithTestId, ComponentPropsWithoutRef<typeof IonSearchbar> {} | ||
|
||
/** | ||
* The `Searchbar` component renders a standardized `IonSearchbar`. | ||
* @param {SearchbarProps} props - Component properties. | ||
* @returns {JSX.Element} JSX | ||
* @see {@link IonSearchbar} | ||
*/ | ||
const Searchbar = ({ | ||
className, | ||
testid = 'ls-searchbar', | ||
...props | ||
}: SearchbarProps): JSX.Element => { | ||
return ( | ||
<IonSearchbar | ||
className={classNames('ls-searchbar', className)} | ||
data-testid={testid} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default Searchbar; |
17 changes: 17 additions & 0 deletions
17
src/common/components/Searchbar/__tests__/Searchbar.test.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,17 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { render, screen } from 'test/test-utils'; | ||
|
||
import Searchbar from '../Searchbar'; | ||
|
||
describe('Searchbar', () => { | ||
it('should render successfully', async () => { | ||
// ARRANGE | ||
render(<Searchbar />); | ||
await screen.findByTestId('ls-searchbar'); | ||
|
||
// ASSERT | ||
expect(screen.getByTestId('ls-searchbar')).toBeDefined(); | ||
expect(screen.getByTestId('ls-searchbar')).toHaveClass('ls-searchbar'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.page-user-list { | ||
.ls-page-user-list { | ||
.page-header { | ||
margin-top: 1rem; | ||
} | ||
|
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,47 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { usersFixture } from '__fixtures__/users'; | ||
|
||
import { filterUsers } from '../users'; | ||
|
||
describe('users', () => { | ||
it('should filter users by name', () => { | ||
// ARRANGE | ||
const result = filterUsers(usersFixture, usersFixture[0].name); | ||
|
||
// ASSERT | ||
expect(result).toBeDefined(); | ||
expect(Array.isArray(result)).toBe(true); | ||
expect(result.length).toBe(1); | ||
}); | ||
|
||
it('should filter users by email', () => { | ||
// ARRANGE | ||
const result = filterUsers(usersFixture, usersFixture[0].email); | ||
|
||
// ASSERT | ||
expect(result).toBeDefined(); | ||
expect(Array.isArray(result)).toBe(true); | ||
expect(result.length).toBe(1); | ||
}); | ||
|
||
it('should not filter users when criteria undefined', () => { | ||
// ARRANGE | ||
const result = filterUsers(usersFixture); | ||
|
||
// ASSERT | ||
expect(result).toBeDefined(); | ||
expect(Array.isArray(result)).toBe(true); | ||
expect(result.length).toBe(usersFixture.length); | ||
}); | ||
|
||
it('should not filter users when criteria empty', () => { | ||
// ARRANGE | ||
const result = filterUsers(usersFixture, ''); | ||
|
||
// ASSERT | ||
expect(result).toBeDefined(); | ||
expect(Array.isArray(result)).toBe(true); | ||
expect(result.length).toBe(usersFixture.length); | ||
}); | ||
}); |
Oops, something went wrong.