parent
25a93d79b7
commit
2b474437f0
@ -71,9 +71,9 @@ const Closet: React.FC = () => {
|
||||
getItems()
|
||||
}, [category, query, page])
|
||||
|
||||
const switchCategory = () => {
|
||||
setCategory((category) => (category === 'skin' ? 'cape' : 'skin'))
|
||||
}
|
||||
const switchCategoryToSkin = () => setCategory('skin')
|
||||
|
||||
const switchCategoryToCape = () => setCategory('cape')
|
||||
|
||||
const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.target.value
|
||||
@ -165,7 +165,7 @@ const Closet: React.FC = () => {
|
||||
className={`nav-link ${category === 'skin' ? 'active' : ''}`}
|
||||
data-toggle="pill"
|
||||
role="tab"
|
||||
onClick={switchCategory}
|
||||
onClick={switchCategoryToSkin}
|
||||
>
|
||||
{t('general.skin')}
|
||||
</a>
|
||||
@ -178,7 +178,7 @@ const Closet: React.FC = () => {
|
||||
}`}
|
||||
data-toggle="pill"
|
||||
role="tab"
|
||||
onClick={switchCategory}
|
||||
onClick={switchCategoryToCape}
|
||||
>
|
||||
{t('general.cape')}
|
||||
</a>
|
||||
|
@ -71,28 +71,6 @@ test('empty closet', async () => {
|
||||
expect(queryByText(/skin library/i)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
test('categories', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
.mockResolvedValueOnce(createPaginator([fixtureCape]))
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
|
||||
const { getByText, queryByText } = render(<Closet />)
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
expect(queryByText(fixtureSkin.pivot.item_name)).toBeInTheDocument()
|
||||
expect(queryByText(fixtureCape.pivot.item_name)).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(getByText(t('general.cape')))
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
expect(queryByText(fixtureSkin.pivot.item_name)).not.toBeInTheDocument()
|
||||
expect(queryByText(fixtureCape.pivot.item_name)).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(getByText(t('general.skin')))
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
expect(queryByText(fixtureSkin.pivot.item_name)).toBeInTheDocument()
|
||||
expect(queryByText(fixtureCape.pivot.item_name)).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
test('search textures', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
@ -118,6 +96,40 @@ test('switch page', async () => {
|
||||
expect(await findByText(fixtureSkin.pivot.item_name)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
describe('switch category', () => {
|
||||
it('click tab', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
.mockResolvedValueOnce(createPaginator([fixtureCape]))
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
|
||||
const { getByText, queryByText } = render(<Closet />)
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
expect(queryByText(fixtureSkin.pivot.item_name)).toBeInTheDocument()
|
||||
expect(queryByText(fixtureCape.pivot.item_name)).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(getByText(t('general.cape')))
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
expect(queryByText(fixtureSkin.pivot.item_name)).not.toBeInTheDocument()
|
||||
expect(queryByText(fixtureCape.pivot.item_name)).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(getByText(t('general.skin')))
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
expect(queryByText(fixtureSkin.pivot.item_name)).toBeInTheDocument()
|
||||
expect(queryByText(fixtureCape.pivot.item_name)).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('click current tab should not switch category', async () => {
|
||||
fetch.get.mockResolvedValue(createPaginator([fixtureSkin]))
|
||||
|
||||
const { getByText } = render(<Closet />)
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
|
||||
fireEvent.click(getByText(t('general.skin')))
|
||||
await waitFor(() => expect(fetch.get).toBeCalledTimes(1))
|
||||
})
|
||||
})
|
||||
|
||||
describe('rename item', () => {
|
||||
beforeEach(() => {
|
||||
fetch.get.mockResolvedValue(createPaginator([fixtureSkin]))
|
||||
|
Loading…
Reference in New Issue
Block a user