|
@@ -1,6 +1,7 @@
|
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
import TableModel from 'app/core/table_model';
|
|
import TableModel from 'app/core/table_model';
|
|
|
import { TableRenderer } from '../renderer';
|
|
import { TableRenderer } from '../renderer';
|
|
|
|
|
+import { SemiDarkOrange } from '@grafana/ui/src/utils/colorsPalette';
|
|
|
|
|
|
|
|
describe('when rendering table', () => {
|
|
describe('when rendering table', () => {
|
|
|
describe('given 13 columns', () => {
|
|
describe('given 13 columns', () => {
|
|
@@ -47,7 +48,7 @@ describe('when rendering table', () => {
|
|
|
decimals: 1,
|
|
decimals: 1,
|
|
|
colorMode: 'value',
|
|
colorMode: 'value',
|
|
|
thresholds: [50, 80],
|
|
thresholds: [50, 80],
|
|
|
- colors: ['green', 'orange', 'red'],
|
|
|
|
|
|
|
+ colors: ['#00ff00', SemiDarkOrange.name, 'rgb(1,0,0)'],
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
pattern: 'String',
|
|
pattern: 'String',
|
|
@@ -138,7 +139,7 @@ describe('when rendering table', () => {
|
|
|
],
|
|
],
|
|
|
colorMode: 'value',
|
|
colorMode: 'value',
|
|
|
thresholds: [1, 2],
|
|
thresholds: [1, 2],
|
|
|
- colors: ['green', 'orange', 'red'],
|
|
|
|
|
|
|
+ colors: ['#00ff00', SemiDarkOrange.name, 'rgb(1,0,0)'],
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
pattern: 'RangeMappingColored',
|
|
pattern: 'RangeMappingColored',
|
|
@@ -158,7 +159,7 @@ describe('when rendering table', () => {
|
|
|
],
|
|
],
|
|
|
colorMode: 'value',
|
|
colorMode: 'value',
|
|
|
thresholds: [2, 5],
|
|
thresholds: [2, 5],
|
|
|
- colors: ['green', 'orange', 'red'],
|
|
|
|
|
|
|
+ colors: ['#00ff00', SemiDarkOrange.name, 'rgb(1,0,0)'],
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
};
|
|
};
|
|
@@ -226,19 +227,19 @@ describe('when rendering table', () => {
|
|
|
expect(html).toBe('<td>asd</td>');
|
|
expect(html).toBe('<td>asd</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it('colored cell should have style', () => {
|
|
|
|
|
|
|
+ it('colored cell should have style (handles HEX color values)', () => {
|
|
|
const html = renderer.renderCell(2, 0, 40);
|
|
const html = renderer.renderCell(2, 0, 40);
|
|
|
- expect(html).toBe('<td style="color:green">40.0</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:#00ff00">40.0</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it('colored cell should have style', () => {
|
|
|
|
|
|
|
+ it('colored cell should have style (handles named color values', () => {
|
|
|
const html = renderer.renderCell(2, 0, 55);
|
|
const html = renderer.renderCell(2, 0, 55);
|
|
|
- expect(html).toBe('<td style="color:orange">55.0</td>');
|
|
|
|
|
|
|
+ expect(html).toBe(`<td style="color:${SemiDarkOrange.variants.dark}">55.0</td>`);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- it('colored cell should have style', () => {
|
|
|
|
|
|
|
+ it('colored cell should have style handles(rgb color values)', () => {
|
|
|
const html = renderer.renderCell(2, 0, 85);
|
|
const html = renderer.renderCell(2, 0, 85);
|
|
|
- expect(html).toBe('<td style="color:red">85.0</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:rgb(1,0,0)">85.0</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('unformated undefined should be rendered as string', () => {
|
|
it('unformated undefined should be rendered as string', () => {
|
|
@@ -333,47 +334,47 @@ describe('when rendering table', () => {
|
|
|
|
|
|
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(11, 0, 1);
|
|
const html = renderer.renderCell(11, 0, 1);
|
|
|
- expect(html).toBe('<td style="color:orange">on</td>');
|
|
|
|
|
|
|
+ expect(html).toBe(`<td style="color:${SemiDarkOrange.variants.dark}">on</td>`);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(11, 0, '1');
|
|
const html = renderer.renderCell(11, 0, '1');
|
|
|
- expect(html).toBe('<td style="color:orange">on</td>');
|
|
|
|
|
|
|
+ expect(html).toBe(`<td style="color:${SemiDarkOrange.variants.dark}">on</td>`);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(11, 0, 0);
|
|
const html = renderer.renderCell(11, 0, 0);
|
|
|
- expect(html).toBe('<td style="color:green">off</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:#00ff00">off</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(11, 0, '0');
|
|
const html = renderer.renderCell(11, 0, '0');
|
|
|
- expect(html).toBe('<td style="color:green">off</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:#00ff00">off</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
it('value should be mapped to text and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(11, 0, '2.1');
|
|
const html = renderer.renderCell(11, 0, '2.1');
|
|
|
- expect(html).toBe('<td style="color:red">2.1</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:rgb(1,0,0)">2.1</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(12, 0, 0);
|
|
const html = renderer.renderCell(12, 0, 0);
|
|
|
- expect(html).toBe('<td style="color:green">0</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:#00ff00">0</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(12, 0, 1);
|
|
const html = renderer.renderCell(12, 0, 1);
|
|
|
- expect(html).toBe('<td style="color:green">on</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:#00ff00">on</td>');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(12, 0, 4);
|
|
const html = renderer.renderCell(12, 0, 4);
|
|
|
- expect(html).toBe('<td style="color:orange">off</td>');
|
|
|
|
|
|
|
+ expect(html).toBe(`<td style="color:${SemiDarkOrange.variants.dark}">off</td>`);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
it('value should be mapped to text (range) and colored cell should have style', () => {
|
|
|
const html = renderer.renderCell(12, 0, '7.1');
|
|
const html = renderer.renderCell(12, 0, '7.1');
|
|
|
- expect(html).toBe('<td style="color:red">7.1</td>');
|
|
|
|
|
|
|
+ expect(html).toBe('<td style="color:rgb(1,0,0)">7.1</td>');
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|