PanelChrome.test.tsx 751 B

12345678910111213141516171819202122232425262728
  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. isFullscreen: false,
  13. } as any);
  14. });
  15. it('Should replace a panel variable', () => {
  16. const out = chrome.replaceVariables('hello $aaa');
  17. expect(out).toBe('hello AAA');
  18. });
  19. it('But it should prefer the local variable value', () => {
  20. const extra = { aaa: { text: '???', value: 'XXX' } };
  21. const out = chrome.replaceVariables('hello $aaa and $bbb', extra);
  22. expect(out).toBe('hello XXX and BBB');
  23. });
  24. });