Skip to content

Commit

Permalink
Add typegen tests for never computed for eventsCausing* and `invoke…
Browse files Browse the repository at this point in the history
…SrcNameMap`
  • Loading branch information
Andarist committed Jan 31, 2022
1 parent 69b3a79 commit 4bf0e45
Showing 1 changed file with 93 additions and 1 deletion.
94 changes: 93 additions & 1 deletion packages/core/test/typegenTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,6 @@ describe('typegen types', () => {

const machine = createMachine({
tsTypes: {} as TypesMeta,

schema: {
context: {} as {
foo: string;
Expand All @@ -1134,4 +1133,97 @@ describe('typegen types', () => {
machine.initialState.context.val;
}
});

it('should error on a provided action where there are no inferred actions', () => {
interface TypesMeta extends TypegenMeta {
eventsCausingActions: never;
}

createMachine(
{
tsTypes: {} as TypesMeta,
schema: {
context: {} as {
foo: string;
}
}
},
{
actions: {
// @ts-expect-error
testAction: () => {}
}
}
);
});

it('should error on a provided delay where there are no inferred delays', () => {
interface TypesMeta extends TypegenMeta {
eventsCausingDelays: never;
}

createMachine(
{
tsTypes: {} as TypesMeta,
schema: {
context: {} as {
foo: string;
}
}
},
{
delays: {
// @ts-expect-error
testDelay: () => {}
}
}
);
});

it('should error on a provided guard where there are no inferred guards', () => {
interface TypesMeta extends TypegenMeta {
eventsCausingGuards: never;
}

createMachine(
{
tsTypes: {} as TypesMeta,
schema: {
context: {} as {
foo: string;
}
}
},
{
guards: {
// @ts-expect-error
testGuard: () => {}
}
}
);
});

it('should error on a provided service where there are no declared services', () => {
interface TypesMeta extends TypegenMeta {
eventsCausingServices: never;
invokeSrcNameMap: never;
}

createMachine(
{
tsTypes: {} as TypesMeta,
schema: {
context: {} as {
foo: string;
}
}
},
{
services: {
// @ts-expect-error
testService: () => Promise.resolve(42)
}
}
);
});
});

0 comments on commit 4bf0e45

Please sign in to comment.