als-statistics
Version:
A powerful and lightweight JavaScript library for descriptive statistics, regression, clustering, outlier detection, and noise analysis using a flexible table/column architecture.
23 lines (19 loc) • 924 B
JavaScript
const { describe, it } = require('node:test');
const assert = require('node:assert');
const getType = require('../../lib/utils/get-type');
describe('getType utility', () => {
it('should return Number for numeric array', () => {
assert.strictEqual(getType([1, 2, 3]), Number);
});
it('should return String for mixed or string array', () => {
assert.strictEqual(getType(['a', 'b', 'c']), String);
assert.strictEqual(getType([1, 'b', 3]), String);
});
it('should throw error for non-array input', () => {
assert.throws(() => getType(null), /Input must be an array/);
});
it('should throw error for non-finite numbers', () => {
assert.throws(() => getType([1, NaN, 3]), /All elements in the array must be finite valid numbers/);
assert.throws(() => getType([1, Infinity, 3]), /All elements in the array must be finite valid numbers/);
});
});