test(ai): cover Cursor usage registration

This commit is contained in:
can1357
2026-07-14 18:03:36 +02:00
parent 594a02e24a
commit 7c49c6cf9f
+36
View File
@@ -1,4 +1,5 @@
import { describe, expect, it } from "bun:test";
import { type AuthCredentialStore, AuthStorage } from "../src/auth-storage";
import type { UsageFetchContext, UsageFetchParams } from "../src/usage";
import { cursorUsageProvider, parseCursorUsage } from "../src/usage/cursor";
@@ -136,6 +137,41 @@ describe("cursor usage provider", () => {
});
});
describe("default registration", () => {
it("registers Cursor in AuthStorage's default usage resolver", async () => {
const store: AuthCredentialStore = {
close() {},
listAuthCredentials() {
return [];
},
updateAuthCredential() {},
deleteAuthCredential() {},
tryDisableAuthCredentialIfMatches() {
return false;
},
replaceAuthCredentialsForProvider() {
return [];
},
upsertAuthCredentialForProvider() {
return [];
},
deleteAuthCredentialsForProvider() {},
getCache() {
return null;
},
setCache() {},
cleanExpiredCache() {},
};
const storage = new AuthStorage(store);
await storage.reload();
try {
expect(storage.usageProviderFor("cursor")).toBe(cursorUsageProvider);
} finally {
storage.close();
}
});
});
describe("cursorUsageProvider", () => {
it("supports oauth credentials", () => {
const params: UsageFetchParams = {