All files / src/table/util inject-props-if-target-not-existed.ts

88.89% Statements 8/9
71.43% Branches 5/7
100% Functions 2/2
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22            4x 4x 2x 1x             4x 3x   1x    
export function injectPropsIfTargetNotExisted(
  columns,
  targetColumnKey,
  columnProps = {}
) {
  // 查找注入的目标列
  let targetColumnIndex = -1;
  if (targetColumnKey) {
    targetColumnIndex = columns.findIndex(x => x.key === targetColumnKey);
    Iif (targetColumnIndex === -1) {
      console.warn(
        `Table addon can not find column "${targetColumnKey}", did you rename or misspell it?`
      );
    }
  }
  // 没有目标列,创建一个列
  if (+targetColumnIndex === -1) {
    return [columnProps, ...columns];
  }
  return columns;
}