Skip to content

Commit

Permalink
test: add start of Assistant class type tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj committed Nov 7, 2024
1 parent 7048251 commit 66797e0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/types/assistant.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { expectError, expectType } from 'tsd';
import { Assistant } from '../../src/Assistant';

// Constructor tests
const asyncNoop = () => Promise.resolve();
// missing required properties `threadStarted` and `userMessage`
expectError(new Assistant({}));
// missing required property `threadStarted`
expectError(
new Assistant({
userMessage: asyncNoop,
}),
);
// missing required property `userMessage`
expectError(
new Assistant({
threadStarted: asyncNoop,
}),
);
// happy construction
expectType<Assistant>(
new Assistant({
threadStarted: asyncNoop,
userMessage: asyncNoop,
}),
);

// threadStarted tests
new Assistant({
userMessage: asyncNoop,
threadStarted: async ({ saveThreadContext }) => {
expectType<void>(await saveThreadContext());
return Promise.resolve();
},
});

0 comments on commit 66797e0

Please sign in to comment.