import { describe, expect, it } from "bun:test";
import { formatBody, formatComments } from "../src/github/data/formatter";
import type { GitHubComment } from "../src/github/types";
describe("Integration: Text Sanitization", () => {
it("should sanitize text in issue body", () => {
const body = `
# Title text
Some content here.
Here's an image:
And a markdown image: 
Check this link: [Click here](https://example.com "link title")
Text with hiddencharacters
');
expect(result).toContain("");
expect(result).toContain("[Click here](https://example.com)");
expect(result).toContain("Content with attributes");
expect(result).toContain("HELLO");
expect(result).toContain('');
});
it("should sanitize text in comments", () => {
const comments: GitHubComment[] = [
{
id: "1",
databaseId: "100001",
body: `Comment text
Check this: 
[Documentation](https://docs.com "doc title")
Textwith characters
Visible text`,
author: { login: "user1" },
createdAt: "2023-01-01T00:00:00Z",
},
];
const result = formatComments(comments);
expect(result).not.toContain("description text");
expect(result).not.toContain("doc title");
expect(result).not.toContain("span label");
expect(result).not.toContain("data value");
expect(result).not.toContain('aria-label="');
expect(result).not.toContain('data-cmd="');
expect(result).not.toContain("\u200B");
expect(result).not.toContain("\u200C");
expect(result).not.toContain("\u200D");
expect(result).toContain("Comment text");
expect(result).toContain("");
expect(result).toContain("[Documentation](https://docs.com)");
expect(result).toContain("Visible text");
expect(result).toContain("Textwith characters");
});
it("should handle complex mixed patterns", () => {
const content = `
Text content here.
Text with reversed content
');
expect(result).toContain("");
expect(result).toContain("[link](url.com)");
expect(result).toContain("Hidden text");
});
it("should handle edge cases with empty attributes", () => {
const edgeCases = `
');
expect(result).toContain("