mirror of
https://github.com/cline/cline.git
synced 2026-10-31 10:58:32 +08:00
* feat: add `string.test.ts` refactor: type improvement of variable `match` in file `src/api/transform/o1-format.ts` * feat: add more test with function `removeInvalidChars`
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { describe, it } from "mocha"
|
|
import "should"
|
|
import { fixModelHtmlEscaping, removeInvalidChars } from "./string"
|
|
|
|
describe("fixModelHtmlEscaping", () => {
|
|
it("should convert > to >", () => {
|
|
fixModelHtmlEscaping("foo > bar").should.equal("foo > bar")
|
|
})
|
|
|
|
it("should convert < to <", () => {
|
|
fixModelHtmlEscaping("foo < bar").should.equal("foo < bar")
|
|
})
|
|
|
|
it('should convert " to "', () => {
|
|
fixModelHtmlEscaping("foo "bar"").should.equal('foo "bar"')
|
|
})
|
|
|
|
it("should convert & to &", () => {
|
|
fixModelHtmlEscaping("foo & bar").should.equal("foo & bar")
|
|
})
|
|
|
|
it("should convert ' to '", () => {
|
|
fixModelHtmlEscaping("foo 'bar'").should.equal("foo 'bar'")
|
|
})
|
|
|
|
it("should handle multiple entities in the same string", () => {
|
|
fixModelHtmlEscaping("<div>Hello "World" & 'Universe'</div>").should.equal(
|
|
"<div>Hello \"World\" & 'Universe'</div>",
|
|
)
|
|
})
|
|
|
|
it("should return unchanged string when no HTML entities are present", () => {
|
|
fixModelHtmlEscaping("normal string").should.equal("normal string")
|
|
})
|
|
})
|
|
|
|
describe("removeInvalidChars", () => {
|
|
it("should remove replacement characters", () => {
|
|
removeInvalidChars("hello\uFFFDworld").should.equal("helloworld")
|
|
})
|
|
|
|
it("should remove � characters", () => {
|
|
removeInvalidChars("hello�world").should.equal("helloworld")
|
|
})
|
|
|
|
it("should remove multiple replacement characters", () => {
|
|
removeInvalidChars("h\uFFFDe\uFFFDl\uFFFDl\uFFFDo").should.equal("hello")
|
|
})
|
|
|
|
it("should remove multiple � characters", () => {
|
|
removeInvalidChars("h�e�l�lo").should.equal("hello")
|
|
})
|
|
|
|
it("should return unchanged string when no replacement characters are present", () => {
|
|
removeInvalidChars("normal string").should.equal("normal string")
|
|
})
|
|
})
|