-
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.
- Loading branch information
Showing
7 changed files
with
150 additions
and
5 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
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,54 @@ | ||
import { describe, it, expect } from 'vitest' | ||
|
||
import { mount } from '@vue/test-utils' | ||
import WPagination from './WPagination.vue' | ||
|
||
describe('WPagination', () => { | ||
it('renders properly', () => { | ||
const wrapper = mount(WPagination, { props: { total: 10, pageSize: 5, page: 1 } }) | ||
|
||
expect(wrapper.element).toMatchSnapshot() | ||
}) | ||
|
||
it('click on page changes current page', async () => { | ||
const wrapper = mount(WPagination, { props: { total: 10, pageSize: 5, page: 1 } }) | ||
|
||
const buttons = wrapper.findAll('button') | ||
|
||
expect(buttons[2].element.textContent).toBe('2') | ||
|
||
await buttons[2].trigger('click') | ||
|
||
const selected = wrapper.find('.bg-wit-blue-500') | ||
|
||
expect(selected.text()).toBe('2') | ||
}) | ||
|
||
it('click on previous changes current page', async () => { | ||
const wrapper = mount(WPagination, { props: { total: 10, pageSize: 5, page: 2 } }) | ||
|
||
const buttons = wrapper.findAll('button') | ||
|
||
expect(buttons[0].element.textContent).toBe('Previous') | ||
|
||
await buttons[0].trigger('click') | ||
|
||
const selected = wrapper.find('.bg-wit-blue-500') | ||
|
||
expect(selected.text()).toBe('1') | ||
}) | ||
|
||
it('click on next changes current page', async () => { | ||
const wrapper = mount(WPagination, { props: { total: 10, pageSize: 5, page: 1 } }) | ||
|
||
const buttons = wrapper.findAll('button') | ||
|
||
expect(buttons[3].element.textContent).toBe('Next') | ||
|
||
await buttons[3].trigger('click') | ||
|
||
const selected = wrapper.find('.bg-wit-blue-500') | ||
|
||
expect(selected.text()).toBe('2') | ||
}) | ||
}) |
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
78 changes: 78 additions & 0 deletions
78
src/components/pagination/__snapshots__/WPagination.spec.ts.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,78 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`WPagination > renders properly 1`] = ` | ||
<nav | ||
aria-label="Pagination" | ||
class="flex items-center gap-xs" | ||
> | ||
<button | ||
aria-label="Previous" | ||
class="opacity-50 pointer-events-none min-h-[38px] min-w-[38px] py-sm px-sm inline-flex justify-center items-center gap-sm text-sm rounded-lg hover:bg-wit-blue-400 focus:outline-none" | ||
disabled="" | ||
type="button" | ||
> | ||
<svg | ||
class="shrink-0 size-3.5" | ||
fill="none" | ||
height="24" | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="m15 18-6-6 6-6" | ||
/> | ||
</svg> | ||
<span> | ||
Previous | ||
</span> | ||
</button> | ||
<div | ||
class="flex items-center gap-x-xs" | ||
> | ||
<button | ||
class="min-h-[38px] min-w-[38px] flex justify-center items-center hover:bg-wit-blue-400 py-sm px-sm text-sm rounded-lg outline-none bg-wit-blue-500 pointer-events-none" | ||
type="button" | ||
> | ||
1 | ||
</button> | ||
<button | ||
class="min-h-[38px] min-w-[38px] flex justify-center items-center hover:bg-wit-blue-400 py-sm px-sm text-sm rounded-lg" | ||
type="button" | ||
> | ||
2 | ||
</button> | ||
</div> | ||
<button | ||
aria-label="Next" | ||
class="min-h-lg min-w-lg py-sm px-sm inline-flex justify-center items-center gap-xs text-sm rounded-lg hover:bg-wit-blue-400 focus:outline-none" | ||
type="button" | ||
> | ||
<span> | ||
Next | ||
</span> | ||
<svg | ||
class="shrink-0 size-3.5" | ||
fill="none" | ||
height="24" | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="m9 18 6-6-6-6" | ||
/> | ||
</svg> | ||
</button> | ||
</nav> | ||
`; |