mirror of
https://github.com/apache/superset.git
synced 2026-04-07 18:35:15 +00:00
refactor(frontend): move utils to TypeScript (#9820)
* refactor(frontend): move utils to typescript (#9101) * refactor(frontend): don't export interfaces * test(frontend): update types and test for isValidChild
This commit is contained in:
@@ -31,7 +31,7 @@ import {
|
||||
TAB_TYPE as TAB,
|
||||
} from 'src/dashboard/util/componentTypes';
|
||||
|
||||
const getIndentation = depth =>
|
||||
const getIndentation = (depth: number) =>
|
||||
Array(depth * 3)
|
||||
.fill('')
|
||||
.join('-');
|
||||
@@ -136,12 +136,14 @@ describe('isValidChild', () => {
|
||||
invalidExamples.forEach((example, exampleIdx) => {
|
||||
let childDepth = 0;
|
||||
example.forEach((childType, i) => {
|
||||
const shouldTestChild = Array.isArray(childType);
|
||||
|
||||
if (i > 0 && shouldTestChild) {
|
||||
// should test child
|
||||
if (i > 0 && Array.isArray(childType)) {
|
||||
const parentDepth = childDepth - 1;
|
||||
const parentType = example[i - 1];
|
||||
|
||||
if (typeof parentType !== 'string')
|
||||
throw TypeError('parent must be string');
|
||||
|
||||
it(`(${exampleIdx})${getIndentation(
|
||||
childDepth,
|
||||
)}${parentType} (depth ${parentDepth}) > ${childType} ❌`, () => {
|
||||
@@ -149,7 +151,7 @@ describe('isValidChild', () => {
|
||||
isValidChild({
|
||||
parentDepth,
|
||||
parentType,
|
||||
childType,
|
||||
childType: childType[0],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
Reference in New Issue
Block a user