test(ai): cover Cursor usage registration
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user