diff --git a/src/ui/public/stringify/__tests__/_color.js b/src/ui/public/stringify/__tests__/_color.js index 05e3021dc902a..d3c9c89beae69 100644 --- a/src/ui/public/stringify/__tests__/_color.js +++ b/src/ui/public/stringify/__tests__/_color.js @@ -1,6 +1,7 @@ import expect from 'expect.js'; import ngMock from 'ng_mock'; import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; + describe('Color Format', function () { let fieldFormats; let ColorFormat; @@ -63,4 +64,42 @@ describe('Color Format', function () { expect(converter('a', 'html')).to.eql('a'); }); }); + + + it('should take into account numerical format', function () { + let colorer = new ColorFormat({ + colors: [{ + range: '100:150', + text: 'blue', + background: 'yellow' + }] + //, + // pattern: '0,0.[000]' + }); + expect(colorer.convert(99.5555, 'html')).to.eql('99.556'); + expect(colorer.convert(100.5555, 'html')).to.eql('100.556'); + expect(colorer.convert(149.5555, 'html')).to.eql('149.556'); + expect(colorer.convert(151.5555, 'html')).to.eql('151.556'); + + }); + + it('should take into account custom numerical format', function () { + let colorer = new ColorFormat({ + colors: [{ + range: '100:150', + text: 'blue', + background: 'yellow' + }], + pattern: '0,0.[00]' + }); + expect(colorer.convert(99.5555, 'html')).to.eql('99.56'); + expect(colorer.convert(100.5555, 'html')).to.eql('100.56'); + expect(colorer.convert(149.5555, 'html')).to.eql('149.56'); + expect(colorer.convert(151.5555, 'html')).to.eql('151.56'); + + }); + + + + }); diff --git a/src/ui/public/stringify/editors/color.html b/src/ui/public/stringify/editors/color.html index 23ab3bd92fb02..35176535eba6f 100644 --- a/src/ui/public/stringify/editors/color.html +++ b/src/ui/public/stringify/editors/color.html @@ -1,4 +1,6 @@