-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
336 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ages/ts-project/__tests__/actions.test.ts → ...ject/__tests__/extraction/actions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...kages/ts-project/__tests__/actors.test.ts → ...oject/__tests__/extraction/actors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s-project/__tests__/createMachine.test.ts → ..._tests__/extraction/createMachine.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...kages/ts-project/__tests__/guards.test.ts → ...oject/__tests__/extraction/guards.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ckages/ts-project/__tests__/state.test.ts → ...roject/__tests__/extraction/state.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../ts-project/__tests__/transitions.test.ts → .../__tests__/extraction/transitions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
new-packages/ts-project/__tests__/source-edits/rename-state.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { expect, test } from 'vitest'; | ||
import { createTestProject, testdir, ts } from '../utils'; | ||
|
||
test('should rename an identifier state key to another identifier state key', async () => { | ||
const tmpPath = await testdir({ | ||
'tsconfig.json': JSON.stringify({}), | ||
'index.ts': ts` | ||
import { createMachine } from "xstate"; | ||
createMachine({ | ||
type: "parallel", | ||
states: { | ||
foo: {}, | ||
bar: {}, | ||
}, | ||
}); | ||
`, | ||
}); | ||
|
||
const project = await createTestProject(tmpPath); | ||
|
||
const textEdits = project.editDigraph( | ||
{ | ||
fileName: 'index.ts', | ||
machineIndex: 0, | ||
}, | ||
{ | ||
type: 'rename_state', | ||
path: ['foo'], | ||
name: 'NEW_NAME', | ||
}, | ||
); | ||
expect(await project.applyTextEdits(textEdits)).toMatchInlineSnapshot( | ||
` | ||
{ | ||
"index.ts": "import { createMachine } from "xstate"; | ||
createMachine({ | ||
type: "parallel", | ||
states: { | ||
"NEW_NAME": {}, | ||
bar: {}, | ||
}, | ||
});", | ||
} | ||
`, | ||
); | ||
}); |
Oops, something went wrong.