Skip to content
Merged
Show file tree
Hide file tree
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
49 changes: 26 additions & 23 deletions types/clerk.io/clerk.io-tests.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
// @ts-expect-error
window.Clerk("click", 1);

// @ts-expect-error
window.Clerk("call", "test");
if (window.Clerk) {
// @ts-expect-error
window.Clerk("click", 1);

(async () => {
if (!window.Clerk) {
return;
}
// @ts-expect-error
window.Clerk("call", "invalid-endpoint");

// $ExpectType ClerkResponseSearchPredictive
const response = await window.Clerk("call", "search/predictive", {
query: "predictive",
// Test basic API calls
window.Clerk("call", "search/predictive", {
key: "test-key",
query: "test",
limit: 5,
}, (response) => {
response.result; // $ExpectType (string | number)[]
response.query; // $ExpectType string
// @ts-expect-error
response.results;
});

// @ts-expect-error
response.results;
// Test config
window.Clerk("config", {
key: "test-key",
visitor: "auto",
});

// $ExpectType number[]
response.result;
// Test cart operations
window.Clerk("cart", "add", "product-123");

const searchResponse = await window.Clerk("call", "search/search", {
query: "test",
limit: 10,
// Test event handling
window.Clerk("on", "rendered", (content) => {
content.element; // $ExpectType HTMLElement
content.more(5);
});

// $ExpectType string
searchResponse.query;
});
}
Loading