Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typegen tests for never computed for eventsCausing* and invokeSrcNameMap #2996

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions packages/core/test/typegenTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,4 +1167,97 @@ describe('typegen types', () => {

acceptMachine(machine);
});

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;
}
}
},
{
// @ts-expect-error
actions: {
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;
}
}
},
{
// @ts-expect-error
delays: {
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;
}
}
},
{
// @ts-expect-error
guards: {
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;
}
}
},
{
// @ts-expect-error
services: {
testService: () => Promise.resolve(42)
}
}
);
});
});