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

@ -8,18 +8,18 @@
<span :title="name">{{ textureName }} <small>({{ type }})</small></span>
</p>
<a
:href="linkToSkinlib"
:title="$t('user.viewInSkinlib')"
class="more"
data-toggle="tooltip"
<a
:href="linkToSkinlib"
:title="$t('user.viewInSkinlib')"
class="more"
data-toggle="tooltip"
data-placement="bottom"
><i class="fa fa-share"></i></a>
<span
:title="$t('general.more')"
class="more"
data-toggle="dropdown"
aria-haspopup="true"
<span
:title="$t('general.more')"
class="more"
data-toggle="dropdown"
aria-haspopup="true"
id="more-button"
><i class="fa fa-cog"></i></span>
@ -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' };
});