Skip to content

Commit

Permalink
chore: restore original isFiniteNumber implementation, lint fixes [PT…
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanik committed Jul 18, 2024
1 parent 0ab4e00 commit 45afcf5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 48 deletions.
71 changes: 32 additions & 39 deletions v3/src/utilities/date-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 45,
subsec: 123
};
expect(isValidDateSpec(validDateSpec)).toEqual(validDateSpec);
});

test('returns null when year is NaN', () => {
}
expect(isValidDateSpec(validDateSpec)).toEqual(validDateSpec)
})
test('returns null when year is NaN', () => {
const invalidDateSpec = {
year: NaN,
month: 7,
Expand All @@ -110,11 +109,10 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 45,
subsec: 123
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});

test('returns null when month is out of range', () => {
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
test('returns null when month is out of range', () => {
const invalidDateSpec = {
year: 2023,
month: 13,
Expand All @@ -123,11 +121,10 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 45,
subsec: 123
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});

test('returns null when day is out of range', () => {
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
test('returns null when day is out of range', () => {
const invalidDateSpec = {
year: 2023,
month: 7,
Expand All @@ -136,11 +133,10 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 45,
subsec: 123
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});

test('returns null when hour is out of range', () => {
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
test('returns null when hour is out of range', () => {
const invalidDateSpec = {
year: 2023,
month: 7,
Expand All @@ -149,11 +145,10 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 45,
subsec: 123
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});

test('returns null when minute is out of range', () => {
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
test('returns null when minute is out of range', () => {
const invalidDateSpec = {
year: 2023,
month: 7,
Expand All @@ -162,11 +157,10 @@ describe('isValidDateSpec', () => {
min: 60,
sec: 45,
subsec: 123
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});

test('returns null when second is out of range', () => {
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
test('returns null when second is out of range', () => {
const invalidDateSpec = {
year: 2023,
month: 7,
Expand All @@ -175,11 +169,10 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 60,
subsec: 123
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});

test('returns null when subsecond is NaN', () => {
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
test('returns null when subsecond is NaN', () => {
const invalidDateSpec = {
year: 2023,
month: 7,
Expand All @@ -188,7 +181,7 @@ describe('isValidDateSpec', () => {
min: 30,
sec: 45,
subsec: NaN
};
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy();
});
});
}
expect(isValidDateSpec(invalidDateSpec)).toBeFalsy()
})
})
8 changes: 0 additions & 8 deletions v3/src/utilities/math-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ describe("math-utils", () => {
expect(isFiniteNumber(-Infinity)).toBe(false)
expect(isFiniteNumber(NaN)).toBe(false)
})
it("should return true for numbers that are strings", () => {
expect(isFiniteNumber("1")).toBe(true)
expect(isFiniteNumber("1.1")).toBe(true)
expect(isFiniteNumber("0")).toBe(true)
expect(isFiniteNumber("Infinity")).toBe(false)
expect(isFiniteNumber("-Infinity")).toBe(false)
expect(isFiniteNumber("NaN")).toBe(false)
})
it("should return false for non-numbers", () => {
expect(isFiniteNumber("")).toBe(false)
expect(isFiniteNumber("foo")).toBe(false)
Expand Down
2 changes: 1 addition & 1 deletion v3/src/utilities/math-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function neededSigDigitsArrayForQuantiles(quantiles: number[], values: nu
}

export function isFiniteNumber(x: any): x is number {
return Number.isFinite(Number.parseFloat(x))
return x != null && Number.isFinite(x)
}

export function goodTickValue(iMin: number, iMax: number) {
Expand Down

0 comments on commit 45afcf5

Please sign in to comment.