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, inputValue: player.player_name,
input: 'text', input: 'text',
showCancelButton: true, showCancelButton: true,
inputValidator: /* istanbul ignore next */ value => inputValidator: value => !value && this.$t('user.emptyPlayerName')
!value && this.$t('user.emptyPlayerName')
}); });
if (dismiss) { if (dismiss) {
return; return;

View File

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