fix modal "applying texture to player"
This commit is contained in:
parent
bfe205ddb3
commit
c0d9d18efc
@ -17,7 +17,7 @@ interface Props {
|
||||
onClose(): void
|
||||
}
|
||||
|
||||
const ModalApply: React.FC<Props> = props => {
|
||||
const ModalApply: React.FC<Props> = (props) => {
|
||||
const [players, setPlayers] = useState<Player[]>([])
|
||||
const [search, setSearch] = useState('')
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
@ -29,10 +29,8 @@ const ModalApply: React.FC<Props> = props => {
|
||||
|
||||
const getPlayers = async () => {
|
||||
setIsLoading(true)
|
||||
const { data } = await fetch.get<fetch.ResponseBody<Player[]>>(
|
||||
'/user/player/list',
|
||||
)
|
||||
setPlayers(data)
|
||||
const players = await fetch.get<Player[]>('/user/player/list')
|
||||
setPlayers(players)
|
||||
setIsLoading(false)
|
||||
}
|
||||
getPlayers()
|
||||
@ -82,8 +80,8 @@ const ModalApply: React.FC<Props> = props => {
|
||||
/>
|
||||
</div>
|
||||
{players
|
||||
.filter(player => player.name.includes(search))
|
||||
.map(player => (
|
||||
.filter((player) => player.name.includes(search))
|
||||
.map((player) => (
|
||||
<button
|
||||
key={player.pid}
|
||||
className="btn btn-block btn-outline-info text-left"
|
||||
|
@ -114,7 +114,7 @@ test('apply to player', async () => {
|
||||
window.blessing.extra.inCloset = true
|
||||
fetch.get
|
||||
.mockResolvedValueOnce({ data: fixtureSkin })
|
||||
.mockResolvedValueOnce({ data: [] })
|
||||
.mockResolvedValueOnce([])
|
||||
|
||||
const { getByText, getByLabelText } = render(<Show />)
|
||||
await waitFor(() => expect(fetch.get).toBeCalledTimes(1))
|
||||
|
@ -383,7 +383,7 @@ describe('apply textures to player', () => {
|
||||
it('search players', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
.mockResolvedValueOnce({ data: [fixturePlayer] })
|
||||
.mockResolvedValueOnce([fixturePlayer])
|
||||
|
||||
const {
|
||||
getByText,
|
||||
@ -408,7 +408,7 @@ describe('apply textures to player', () => {
|
||||
it('succeeded', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
.mockResolvedValueOnce({ data: [fixturePlayer] })
|
||||
.mockResolvedValueOnce([fixturePlayer])
|
||||
fetch.post.mockResolvedValue({ code: 0, message: 'success' })
|
||||
|
||||
const {
|
||||
@ -439,7 +439,7 @@ describe('apply textures to player', () => {
|
||||
it('failed', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
.mockResolvedValueOnce({ data: [fixturePlayer] })
|
||||
.mockResolvedValueOnce([fixturePlayer])
|
||||
fetch.post.mockResolvedValue({ code: 1, message: 'failed' })
|
||||
|
||||
const {
|
||||
@ -470,7 +470,7 @@ describe('apply textures to player', () => {
|
||||
it('close dialog', async () => {
|
||||
fetch.get
|
||||
.mockResolvedValueOnce(createPaginator([fixtureSkin]))
|
||||
.mockResolvedValueOnce({ data: [fixturePlayer] })
|
||||
.mockResolvedValueOnce([fixturePlayer])
|
||||
|
||||
const { getByText, getByAltText } = render(<Closet />)
|
||||
await waitFor(() => expect(fetch.get).toBeCalled())
|
||||
|
Loading…
Reference in New Issue
Block a user