mirror of
https://github.com/apache/superset.git
synced 2026-04-10 20:06:13 +00:00
* [lint] turn no-undef back on, set browser, cypress, and mocha env's, and fix issues * [lint] fix undefined var in TimeTable.jsx
41 lines
1017 B
JavaScript
41 lines
1017 B
JavaScript
import { expect } from 'chai';
|
|
|
|
import getChartIdsFromLayout from '../../../../src/dashboard/util/getChartIdsFromLayout';
|
|
import {
|
|
ROW_TYPE,
|
|
CHART_TYPE,
|
|
} from '../../../../src/dashboard/util/componentTypes';
|
|
|
|
describe('getChartIdsFromLayout', () => {
|
|
const mockLayout = {
|
|
a: {
|
|
id: 'a',
|
|
type: CHART_TYPE,
|
|
meta: { chartId: 'A' },
|
|
},
|
|
b: {
|
|
id: 'b',
|
|
type: CHART_TYPE,
|
|
meta: { chartId: 'B' },
|
|
},
|
|
c: {
|
|
id: 'c',
|
|
type: ROW_TYPE,
|
|
meta: { chartId: 'C' },
|
|
},
|
|
};
|
|
|
|
it('should return an array of chartIds', () => {
|
|
const result = getChartIdsFromLayout(mockLayout);
|
|
expect(Array.isArray(result)).to.equal(true);
|
|
expect(result.includes('A')).to.equal(true);
|
|
expect(result.includes('B')).to.equal(true);
|
|
});
|
|
|
|
it('should return ids only from CHART_TYPE components', () => {
|
|
const result = getChartIdsFromLayout(mockLayout);
|
|
expect(result.length).to.equal(2);
|
|
expect(result.includes('C')).to.equal(false);
|
|
});
|
|
});
|