mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -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
26 lines
844 B
JavaScript
26 lines
844 B
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 { sqrt } = require('../../src/functions/sqrt.js');
|
|
|
|
describe('Sqrt', () => {
|
|
it('numbers', () => {
|
|
expect(sqrt(9)).toEqual(3);
|
|
expect(sqrt(0)).toEqual(0);
|
|
expect(sqrt(30)).toEqual(5.477225575051661);
|
|
});
|
|
|
|
it('arrays', () => {
|
|
expect(sqrt([49, 64, 81])).toEqual([7, 8, 9]);
|
|
expect(sqrt([1, 4, 100])).toEqual([1, 2, 10]);
|
|
});
|
|
|
|
it('Invalid negative number', () => {
|
|
expect(() => sqrt(-1)).toThrow('Unable find the square root of a negative number');
|
|
});
|
|
});
|