fix(variable): should not return undefined when parsing 0 (#2766)
This commit is contained in:
parent
f5399c2cf0
commit
0d67141a6b
@ -94,4 +94,10 @@ describe('getValuesByPath', () => {
|
||||
const result = getValuesByPath(arr, 'b', []);
|
||||
expect(result).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('should return 0 when the initial value is 0', () => {
|
||||
const obj = { a: 0 };
|
||||
const result = getValuesByPath(obj, 'a');
|
||||
expect(result).toBe(0);
|
||||
});
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ export const getValuesByPath = (obj: object, path: string, defaultValue?: any) =
|
||||
}
|
||||
}
|
||||
|
||||
result = result.filter(Boolean);
|
||||
result = result.filter((item) => item != null);
|
||||
|
||||
if (result.length === 0) {
|
||||
return defaultValue;
|
||||
|
@ -24,7 +24,7 @@
|
||||
"module": "commonjs"
|
||||
}
|
||||
},
|
||||
"include": ["packages/**/*", ".dumi/**/*", ".dumirc.ts", "scripts/*", "playwright.config.ts"],
|
||||
"include": ["packages/**/*", ".dumi/**/*", ".dumirc.ts", "scripts/*", "playwright.config.ts", "vitest.config.ts"],
|
||||
"exclude": [
|
||||
"packages/**/node_modules",
|
||||
"packages/**/dist",
|
||||
|
@ -34,7 +34,7 @@ export default defineConfig({
|
||||
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
||||
...alias,
|
||||
],
|
||||
include: ['packages/**/{dumi-theme-nocobase,sdk,client}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
|
||||
include: ['packages/**/{dumi-theme-nocobase,sdk,client,utils}/**/__tests__/**/*.{test,spec}.{ts,tsx}'],
|
||||
exclude: [
|
||||
'**/node_modules/**',
|
||||
'**/dist/**',
|
||||
|
Loading…
Reference in New Issue
Block a user