Simplify input validator

This commit is contained in:
Pig Fang 2018-08-05 14:36:44 +08:00
parent 33de864504
commit a2e6315198
2 changed files with 14 additions and 16 deletions

View File

@ -74,9 +74,7 @@ export default {
input: 'text',
inputValue: this.textureName,
showCancelButton: true,
inputValidator: value => (new Promise(resolve => {
value ? resolve() : resolve(this.$t('skinlib.emptyNewTextureName'));
}))
inputValidator: value => !value && this.$t('skinlib.emptyNewTextureName')
});
if (dismiss) {
return;

View File

@ -40,10 +40,10 @@ test('rename texture', async () => {
axios.post
.mockResolvedValueOnce({ data: { errno: 0 } })
.mockResolvedValueOnce({ data: { errno: 1 } });
swal.mockImplementationOnce(() => Promise.resolve({ dismiss: 'cancel' }))
.mockImplementation(async options => {
swal.mockImplementationOnce(() => ({ dismiss: 'cancel' }))
.mockImplementation(options => {
options.inputValidator('name');
options.inputValidator().catch(() => {});
options.inputValidator();
return { value: 'new-name' };
});