PanelChrome.test.tsx 900 B

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