openclaw/extensions/msteams/src/graph-chat.test.ts

41 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { buildTeamsFileInfoCard } from "./graph-chat.js";
describe("buildTeamsFileInfoCard", () => {
it("extracts a unique id from quoted etags and lowercases file extensions", () => {
expect(
buildTeamsFileInfoCard({
eTag: '"{ABC-123},42"',
name: "Quarterly.Report.PDF",
webDavUrl: "https://sharepoint.example.com/file.pdf",
}),
).toEqual({
contentType: "application/vnd.microsoft.teams.card.file.info",
contentUrl: "https://sharepoint.example.com/file.pdf",
name: "Quarterly.Report.PDF",
content: {
uniqueId: "ABC-123",
fileType: "pdf",
},
});
});
it("keeps the raw etag when no version suffix exists and handles extensionless files", () => {
expect(
buildTeamsFileInfoCard({
eTag: "plain-etag",
name: "README",
webDavUrl: "https://sharepoint.example.com/readme",
}),
).toEqual({
contentType: "application/vnd.microsoft.teams.card.file.info",
contentUrl: "https://sharepoint.example.com/readme",
name: "README",
content: {
uniqueId: "plain-etag",
fileType: "",
},
});
});
});