mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:35:20 +00:00
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', []);
|
const result = getValuesByPath(arr, 'b', []);
|
||||||
expect(result).toEqual([1, 2]);
|
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) {
|
if (result.length === 0) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
"module": "commonjs"
|
"module": "commonjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["packages/**/*", ".dumi/**/*", ".dumirc.ts", "scripts/*", "playwright.config.ts"],
|
"include": ["packages/**/*", ".dumi/**/*", ".dumirc.ts", "scripts/*", "playwright.config.ts", "vitest.config.ts"],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"packages/**/node_modules",
|
"packages/**/node_modules",
|
||||||
"packages/**/dist",
|
"packages/**/dist",
|
||||||
|
@ -34,7 +34,7 @@ export default defineConfig({
|
|||||||
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
{ find: /^~antd\/(.*)/, replacement: 'antd/$1' },
|
||||||
...alias,
|
...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: [
|
exclude: [
|
||||||
'**/node_modules/**',
|
'**/node_modules/**',
|
||||||
'**/dist/**',
|
'**/dist/**',
|
||||||
|
Loading…
Reference in New Issue
Block a user