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:
Christian Murphy
2020-05-20 14:47:40 -07:00
committed by GitHub
parent ef6af935fc
commit a262ea7487
13 changed files with 60 additions and 21 deletions

View File

@@ -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);
});