The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/scripts/webpack/getThemeVariable.test.js

40 lines
1.2 KiB

const sass = require('node-sass');
const getThemeVariable = require('./getThemeVariable');
const { mockTheme } = require('@grafana/ui');
const themeMock = {
color: {
background: '#ff0000',
},
spacing: {
padding: '2em',
},
typography: {
fontFamily: 'Arial, sans-serif',
},
};
describe('Variables retrieval', () => {
const restoreTheme = mockTheme(() => themeMock);
afterAll(() => {
restoreTheme();
});
it('returns sass Color for color values', () => {
const result = getThemeVariable({ getValue: () => 'color.background' }, { getValue: () => {} });
expect(result).toBeInstanceOf(sass.types.Color);
});
it('returns sass Number for dimension values', () => {
const result = getThemeVariable({ getValue: () => 'spacing.padding' }, { getValue: () => {} });
expect(result).toBeInstanceOf(sass.types.Number);
});
it('returns sass String for string values', () => {
const result = getThemeVariable({ getValue: () => 'typography.fontFamily' }, { getValue: () => {} });
expect(result).toBeInstanceOf(sass.types.String);
});
it('throws for unknown theme paths', () => {
expect(() => getThemeVariable({ getValue: () => 'what.ever' }, { getValue: () => {} })).toThrow();
});
});