mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-04 21:07:21 +03:00
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:
parent
b0ac0f27c5
commit
8c5cbec8d8
@ -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;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user