Added example of custom tests transformation (#679)

* Added example of custom tests transformation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update docs/contributing/test-case-recorder.md

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
This commit is contained in:
Andreas Arvidsson 2022-05-18 10:54:58 +02:00 committed by GitHub
parent b0ac0f27c5
commit 8c5cbec8d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,3 +71,29 @@ To upgrade all the test fixtures to the latest command version, run the command
[`transformRecordedTests/index.ts`](../../src/scripts/transformRecordedTests/index.ts) to
point to your new transformation
1. Run `yarn run compile && node ./out/scripts/transformRecordedTests/index.js custom`
Example of a custom transformation
```typescript
export function updateSurroundingPairTest(fixture: TestCaseFixture) {
fixture.command.targets = transformPartialPrimitiveTargets(
fixture.command.targets,
(target: PartialPrimitiveTargetDesc) => {
target.modifiers?.forEach((modifier) => {
if (modifier?.type === "surroundingPair") {
let delimiterInclusion: DelimiterInclusion;
switch (modifier.delimiterInclusion as any) {
case "includeDelimiters":
delimiterInclusion = undefined;
break;
case "excludeDelimiters":
delimiterInclusion = "interiorOnly";
break;
case "delimitersOnly":
delimiterInclusion = "excludeInterior";
break;
}
modifier.delimiterInclusion = delimiterInclusion;
}
});
```