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