Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jan 23, 2024
1 parent de66d37 commit ba24e79
Show file tree
Hide file tree
Showing 7 changed files with 2,224 additions and 409 deletions.
6 changes: 6 additions & 0 deletions new-packages/ts-project/__tests__/actors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ test('should extract an actor with string src (direct)', async () => {
]
`);
});

test('should extract multiple actors with different string sources (direct)', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -208,6 +209,7 @@ test('should extract multiple actors with different string sources (direct)', as
]
`);
});

test('should extract multiple actors with the same string source (direct)', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -336,6 +338,7 @@ test('should extract multiple actors with the same string source (direct)', asyn
]
`);
});

test('should extract multiple actors with string source (array)', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -452,6 +455,7 @@ test('should extract multiple actors with string source (array)', async () => {
]
`);
});

test('should extract actor with inline source (direct)', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -585,6 +589,7 @@ test('should extract actor with inline source (direct)', async () => {
]
`);
});

test('should raise error if actor is missing src property', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -663,6 +668,7 @@ test('should raise error if actor is missing src property', async () => {
]
`);
});

test('should extract actor id if it is present with a string value', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down
7 changes: 7 additions & 0 deletions new-packages/ts-project/__tests__/guards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ test('should extract guard from transition (string)', async () => {
]
`);
});

test('should extract guard (inline)', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -267,6 +268,7 @@ test('should extract guard (inline)', async () => {
]
`);
});

test('should extract parameterized guards', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -402,6 +404,7 @@ test('should extract parameterized guards', async () => {
]
`);
});

test('should extract higher order guards as inline', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -535,6 +538,7 @@ test('should extract higher order guards as inline', async () => {
]
`);
});

test('should extract multiple guards', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -767,6 +771,7 @@ test('should extract multiple guards', async () => {
]
`);
});

test('should support XState v4 guard', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -900,6 +905,7 @@ test('should support XState v4 guard', async () => {
]
`);
});

test('should raise error if both guard and cond are provided, pick guard over cond and extract transition (cond before guard)', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -1298,6 +1304,7 @@ test('should raise error for parameterized guard is missing type property', asyn
]
`);
});

test('should raise error for parameterized guard with invalid type property', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down
6 changes: 5 additions & 1 deletion new-packages/ts-project/__tests__/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ test('should extract state.initial with string value', async () => {
]
`);
});

test('should extract state.initial with template literal value', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -804,6 +805,7 @@ test('should extract state.history with value "shallow"', async () => {
]
`);
});

test('should extract state.history with value "deep"', async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -1455,6 +1457,7 @@ test("should extract state.meta when it's a javascript object", async () => {
]
`);
});

test("should extract state.meta when it's a javascript object containing nested array items", async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -1550,6 +1553,7 @@ test("should extract state.meta when it's a javascript object containing nested
]
`);
});

test("should extract state.meta when it's a javascript object and contains multi level object value", async () => {
const tmpPath = await testdir({
'tsconfig.json': JSON.stringify({}),
Expand Down Expand Up @@ -1732,7 +1736,7 @@ test('should raise error when state.meta contains any value other than a plain j
initial: 'foo'
states: {
foo: {
meta: 'some string meta'
meta: 'some string meta'
}
},
});
Expand Down
Loading

0 comments on commit ba24e79

Please sign in to comment.