singlestat_panel_spec.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
  2. import {getColorForValue} from '../module';
  3. describe('grafanaSingleStat', function() {
  4. describe('legacy thresholds', () => {
  5. describe('positive thresholds', () => {
  6. var data: any = {
  7. colorMap: ['green', 'yellow', 'red'],
  8. thresholds: [20, 50]
  9. };
  10. it('5 should return green', () => {
  11. expect(getColorForValue(data, 5)).to.be('green');
  12. });
  13. it('25 should return green', () => {
  14. expect(getColorForValue(data, 25)).to.be('yellow');
  15. });
  16. it('55 should return green', () => {
  17. expect(getColorForValue(data, 55)).to.be('red');
  18. });
  19. });
  20. });
  21. describe('negative thresholds', () => {
  22. var data: any = {
  23. colorMap: ['green', 'yellow', 'red'],
  24. thresholds: [ 0, 20]
  25. };
  26. it('-30 should return green', () => {
  27. expect(getColorForValue(data, -30)).to.be('green');
  28. });
  29. it('1 should return green', () => {
  30. expect(getColorForValue(data, 1)).to.be('yellow');
  31. });
  32. it('22 should return green', () => {
  33. expect(getColorForValue(data, 22)).to.be('red');
  34. });
  35. });
  36. describe('negative thresholds', () => {
  37. var data: any = {
  38. colorMap: ['green', 'yellow', 'red'],
  39. thresholds: [-27, 20]
  40. };
  41. it('-30 should return green', () => {
  42. expect(getColorForValue(data, -26)).to.be('yellow');
  43. });
  44. });
  45. });