PanelChrome.test.tsx 783 B

123456789101112131415161718192021222324252627282930
  1. import { PanelChrome } from './PanelChrome';
  2. describe('PanelChrome', () => {
  3. let chrome: PanelChrome;
  4. beforeEach(() => {
  5. chrome = new PanelChrome({
  6. panel: {
  7. scopedVars: {
  8. aaa: { value: 'AAA', text: 'upperA' },
  9. bbb: { value: 'BBB', text: 'upperB' },
  10. },
  11. },
  12. dashboard: {},
  13. plugin: {},
  14. isFullscreen: false,
  15. });
  16. });
  17. it('Should replace a panel variable', () => {
  18. const out = chrome.replaceVariables('hello $aaa');
  19. expect(out).toBe('hello AAA');
  20. });
  21. it('But it should prefer the local variable value', () => {
  22. const extra = { aaa: { text: '???', value: 'XXX' } };
  23. const out = chrome.replaceVariables('hello $aaa and $bbb', extra);
  24. expect(out).toBe('hello XXX and BBB');
  25. });
  26. });