Skip to content

Commit

Permalink
[chore]: fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
LZS911 committed Feb 22, 2024
1 parent 8b708e3 commit 7ac0db4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/shared/lib/utils/Tool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function formatParamsBySeparator(formatParams: string | number) {
export function formatParamsBySeparator(formatParams: string | number): string {
if (Number.isNaN(formatParams)) {
return formatParams;
return 'NaN';
}
const val =
typeof formatParams === 'number' ? formatParams + '' : formatParams;
Expand Down
8 changes: 7 additions & 1 deletion packages/shared/lib/utils/__tests__/Tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { formatParamsBySeparator, fuzzySearchAndSortByWeight } from '../Tool';

describe('test utils/Tool', () => {
it('test formatParamsBySeparator', () => {
expect(formatParamsBySeparator(NaN)).toBe(NaN);
expect(formatParamsBySeparator(NaN)).toBe('NaN');

expect(formatParamsBySeparator(0)).toBe('0');
expect(formatParamsBySeparator(33)).toBe('33');
Expand Down Expand Up @@ -38,9 +38,15 @@ describe('test utils/Tool', () => {
{ a: 'test1' },
{ a: 'test-1' }
]);
expect(fuzzySearchAndSortByWeight('tes', data, 'a')).toEqual([
{ a: 'tes' },
{ a: 'test1' },
{ a: 'test-1' }
]);
expect(fuzzySearchAndSortByWeight('test', data, 'a')).toEqual([
{ a: 'test1' },
{ a: 'test-1' }
]);
expect(fuzzySearchAndSortByWeight('test', data, 'a1' as any)).toEqual([]);
});
});

0 comments on commit 7ac0db4

Please sign in to comment.