mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
* Tinymath is now a Kibana package * Rename to @kbn/tinymath * Update import style * Update README * Use commonjs import syntax * Fix to commonjs export * More commonjs fixes
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* and the Server Side Public License, v 1; you may not use this file except in
|
|
* compliance with, at your election, the Elastic License or the Server Side
|
|
* Public License, v 1.
|
|
*/
|
|
|
|
const { log } = require('../../src/functions/log.js');
|
|
|
|
describe('Log', () => {
|
|
it('numbers', () => {
|
|
expect(log(1)).toEqual(Math.log(1));
|
|
expect(log(3, 2)).toEqual(Math.log(3) / Math.log(2));
|
|
expect(log(11, 3)).toEqual(Math.log(11) / Math.log(3));
|
|
expect(log(42, 5)).toEqual(2.322344707681546);
|
|
});
|
|
|
|
it('arrays', () => {
|
|
expect(log([3, 4, 5], 3)).toEqual([
|
|
Math.log(3) / Math.log(3),
|
|
Math.log(4) / Math.log(3),
|
|
Math.log(5) / Math.log(3),
|
|
]);
|
|
expect(log([1, 2, 10], 10)).toEqual([
|
|
Math.log(1) / Math.log(10),
|
|
Math.log(2) / Math.log(10),
|
|
Math.log(10) / Math.log(10),
|
|
]);
|
|
});
|
|
|
|
it('number less than 1', () => {
|
|
expect(() => log(-1)).toThrow('Must be greater than 0');
|
|
});
|
|
|
|
it('base out of range', () => {
|
|
expect(() => log(1, -1)).toThrow('Base out of range');
|
|
});
|
|
});
|