Skip to content

Commit

Permalink
chore: fix jest config (#329)
Browse files Browse the repository at this point in the history
* chore: fix jest config

* refactor: fix utils types
  • Loading branch information
Aarebecca authored Oct 21, 2024
1 parent 51ba842 commit 14c6ba1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const esm = ['internmap', 'd3-*', 'lodash-es'].map((d) => `_${d}|${d}`).join('|'

module.exports = {
testTimeout: 100000,
preset: 'ts-jest/presets/js-with-ts',
preset: 'ts-jest',
testEnvironment: 'jsdom',
transform: {
'\\.[jt]sx?$': [
'^.+\\.[tj]s$': [
'ts-jest',
{
isolatedModules: true,
tsconfig: {
target: 'esnext', // Increase test coverage.
allowJs: true,
Expand All @@ -28,5 +29,5 @@ module.exports = {
'!**/(countdown|statistic|link|toolbox)/**',
],
// Transform esm to cjs.
transformIgnorePatterns: [`<rootDir>/node_modules/(?!(${esm}))`],
transformIgnorePatterns: [`<rootDir>/node_modules/(?!(?:.pnpm/)?(${esm}))`],
};
5 changes: 4 additions & 1 deletion src/ui/sparkline/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import type { Data } from './types';
*/
export function getRange(data: Data): [number, number] {
if (data.length === 0) return [0, 0];
return [min(minBy(data, (arr) => min(arr) || 0)), max(maxBy(data, (arr) => max(arr) || 0))] as [number, number];
return [
min(minBy(data, (arr) => min(arr) || 0) as number[]),
max(maxBy(data, (arr) => max(arr) || 0) as number[]),
] as [number, number];
}

/**
Expand Down

0 comments on commit 14c6ba1

Please sign in to comment.