mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' into toni-moreno-add_shared_tooltips_to_graphs
This commit is contained in:
@@ -3,76 +3,31 @@ define([
|
||||
], function(kbn) {
|
||||
'use strict';
|
||||
|
||||
describe('millisecond formating', function() {
|
||||
function describeValueFormat(desc, value, tickSize, tickDecimals, result) {
|
||||
|
||||
it('should translate 4378634603 as 1.67 years', function() {
|
||||
var str = kbn.msFormat(4378634603, 2);
|
||||
expect(str).to.be('50.68 day');
|
||||
describe('value format: ' + desc, function() {
|
||||
it('should translate ' + value + ' as ' + result, function() {
|
||||
var scaledDecimals = tickDecimals - Math.floor(Math.log(tickSize) / Math.LN10);
|
||||
var str = kbn.valueFormats[desc](value, tickDecimals, scaledDecimals);
|
||||
expect(str).to.be(result);
|
||||
});
|
||||
});
|
||||
|
||||
it('should translate 3654454 as 1.02 hour', function() {
|
||||
var str = kbn.msFormat(3654454, 2);
|
||||
expect(str).to.be('1.02 hour');
|
||||
});
|
||||
}
|
||||
|
||||
it('should not downscale when value is zero', function() {
|
||||
var str = kbn.msFormat(0, 2);
|
||||
expect(str).to.be('0.00 ms');
|
||||
});
|
||||
describeValueFormat('ms', 0.0024, 0.0005, 4, '0.0024 ms');
|
||||
describeValueFormat('ms', 100, 1, 0, '100 ms');
|
||||
describeValueFormat('ms', 1250, 10, 0, '1.25 s');
|
||||
describeValueFormat('ms', 1250, 300, 0, '1.3 s');
|
||||
describeValueFormat('ms', 65150, 10000, 0, '1.1 min');
|
||||
describeValueFormat('ms', 6515000, 1500000, 0, '1.8 hour');
|
||||
describeValueFormat('ms', 651500000, 150000000, 0, '8 day');
|
||||
|
||||
describeValueFormat('none', 2.75e-10, 0, 10, '3e-10');
|
||||
describeValueFormat('none', 0, 0, 2, '0');
|
||||
|
||||
it('should translate 365445 as 6.09 min', function() {
|
||||
var str = kbn.msFormat(365445, 2);
|
||||
expect(str).to.be('6.09 min');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('high negative exponent, issue #696', function() {
|
||||
it('should ignore decimal correction if exponent', function() {
|
||||
var str = kbn.getFormatFunction('')(2.75e-10, { tickDecimals: 12 });
|
||||
expect(str).to.be('2.75e-10');
|
||||
});
|
||||
it('should format 0 correctly', function() {
|
||||
var str = kbn.getFormatFunction('')(0.0, { tickDecimals: 12 });
|
||||
expect(str).to.be('0');
|
||||
});
|
||||
});
|
||||
|
||||
describe('none format tests', function() {
|
||||
it('should translate 2 as 2.0000 if axis decimals is 4', function() {
|
||||
var str = kbn.getFormatFunction('')(2, { tickDecimals: 4 });
|
||||
expect(str).to.be('2.0000');
|
||||
});
|
||||
});
|
||||
|
||||
describe('nanosecond formatting', function () {
|
||||
it('should translate 25 to 25 ns', function () {
|
||||
var str = kbn.nanosFormat(25, 2);
|
||||
expect(str).to.be("25 ns");
|
||||
});
|
||||
|
||||
it('should translate 2558 to 2.56 µs', function () {
|
||||
var str = kbn.nanosFormat(2558, 2);
|
||||
expect(str).to.be("2.56 µs");
|
||||
});
|
||||
|
||||
it('should translate 2558000 to 2.56 ms', function () {
|
||||
var str = kbn.nanosFormat(2558000, 2);
|
||||
expect(str).to.be("2.56 ms");
|
||||
});
|
||||
|
||||
it('should translate 2019962000 to 2.02 s', function () {
|
||||
var str = kbn.nanosFormat(2049962000, 2);
|
||||
expect(str).to.be("2.05 s");
|
||||
});
|
||||
|
||||
it('should translate 95199620000 to 1.59 m', function () {
|
||||
var str = kbn.nanosFormat(95199620000, 2);
|
||||
expect(str).to.be("1.59 m");
|
||||
});
|
||||
|
||||
});
|
||||
describeValueFormat('ns', 25, 1, 0, '25 ns');
|
||||
describeValueFormat('ns', 2558, 50, 0, '2.56 µs');
|
||||
|
||||
describe('calculateInterval', function() {
|
||||
it('1h 100 resultion', function() {
|
||||
|
||||
Reference in New Issue
Block a user