Skip to content

Commit

Permalink
Fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanmiu committed Nov 1, 2023
1 parent a89ee46 commit d23b0d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/patcher/paragraph-token-replacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const replaceTokenInParagraphElement = ({
patchTextElement(paragraphElement.elements![run.index].elements![index], firstPart);
replaceMode = ReplaceMode.MIDDLE;
continue;
/* c8 ignore next 2 */
}
break;
case ReplaceMode.MIDDLE:
Expand All @@ -59,6 +60,7 @@ export const replaceTokenInParagraphElement = ({
patchTextElement(paragraphElement.elements![run.index].elements![index], "");
}
break;
/* c8 ignore next */
default:
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/patcher/replacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,18 @@ export const replacer = (
let patchedRightElement = right;

if (keepOriginalStyles) {
const runElementNonTextualElements =
runElementToBeReplaced.elements?.filter((e) => e.type === "element" && e.name !== "w:t") ?? [];
const runElementNonTextualElements = runElementToBeReplaced.elements!.filter(
(e) => e.type === "element" && e.name !== "w:t",
);

newRunElements = textJson.map((e) => ({
...e,
elements: [...runElementNonTextualElements, ...(e.elements ?? [])],
elements: [...runElementNonTextualElements, ...e.elements!],
}));

patchedRightElement = {
...right,
elements: [...runElementNonTextualElements, ...(right.elements ?? [])],
elements: [...runElementNonTextualElements, ...right.elements!],
};
}

Expand Down

0 comments on commit d23b0d0

Please sign in to comment.