Fix risky test

This commit is contained in:
Pig Fang 2018-08-16 16:46:46 +08:00
parent 767436610c
commit d657e88dd8
2 changed files with 9 additions and 4 deletions

View File

@ -346,8 +346,7 @@ export default {
inputValue: player.player_name,
input: 'text',
showCancelButton: true,
inputValidator: /* istanbul ignore next */ value =>
!value && this.$t('user.emptyPlayerName')
inputValidator: value => !value && this.$t('user.emptyPlayerName')
});
if (dismiss) {
return;

View File

@ -90,8 +90,14 @@ test('change player name', async () => {
Vue.prototype.$http.post
.mockResolvedValueOnce({ errno: 1 })
.mockResolvedValue({ errno: 0 });
swal.mockResolvedValueOnce({ dismiss: 1 })
.mockResolvedValue({ value: 'new-name' });
swal.mockImplementationOnce(() => ({ dismiss: 1 }))
.mockImplementation(({ inputValidator }) => {
if (inputValidator) {
inputValidator();
inputValidator('new-name');
return { value: 'new-name' };
}
});
const wrapper = mount(Players);
await wrapper.vm.$nextTick();
const button = wrapper.find('.btn-default');