From 9fe7936e57c251d797fc8950c714b90ac1656b61 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Mon, 16 Sep 2019 02:22:31 +0200 Subject: [PATCH] fix: fix param existence check in interpolation closes #2332 --- src/utils/index.ts | 2 +- tests/providers/provider.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 81f8261ec..b13f598ef 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -305,7 +305,7 @@ export const isEmptyArray = (arr: any[]): boolean => { export const interpolate = (template: string, values: Record): string => { return template.replace(/\{([^}]+)\}/g, (_, p): string => { - return values[p] || `{${p}}`; + return p in values ? values[p] : `{${p}}`; }); }; diff --git a/tests/providers/provider.js b/tests/providers/provider.js index c6d88b209..e8bfabd8a 100644 --- a/tests/providers/provider.js +++ b/tests/providers/provider.js @@ -327,7 +327,7 @@ test('validates on rule change: testing NaN', async () => { // flush the pending validation. await flushPromises(); - expect(error.text()).toBe('The {field} field may not be greater than {length} characters'); + expect(error.text()).toBe('The {field} field may not be greater than NaN characters'); wrapper.vm.rules = { required: true, @@ -335,7 +335,7 @@ test('validates on rule change: testing NaN', async () => { }; await flushPromises(); - expect(error.text()).toBe('The {field} field may not be greater than {length} characters'); + expect(error.text()).toBe('The {field} field may not be greater than NaN characters'); }); test('validates components on input by default', async () => {