Compare commits

...

1 Commits

Author SHA1 Message Date
Dylan Conway
acf4bb71a6 don't character diff emojis 2023-11-02 16:44:21 -07:00
2 changed files with 21 additions and 1 deletions

View File

@@ -4543,7 +4543,11 @@ pub const JSValue = enum(JSValueReprInt) {
};
pub fn determineDiffMethod(this: JSValue, other: JSValue, global: *JSGlobalObject) DiffMethod {
if ((this.isString() and other.isString()) or (this.isBuffer(global) and other.isBuffer(global))) return .character;
if ((this.isString() and other.isString())) {
if (this.toString(global).is8Bit() and other.toString(global).is8Bit()) return .character;
return .none;
}
if (this.isBuffer(global) and other.isBuffer(global)) return .character;
if ((this.isRegExp() and other.isObject()) or (this.isObject() and other.isRegExp())) return .character;
if (this.isObject() and other.isObject()) return .line;

View File

@@ -1914,6 +1914,22 @@ describe("expect()", () => {
expect(1).not.toBe("1");
expect("hello test").toBe("hello test");
expect("hello test").not.toBe("hello test2");
expect(() => {
expect("🟢🟢🟢").toBe("🔴🔴🔴");
}).toThrow("🔴🔴🔴");
expect(() => {
expect(String("🟢🟢🟢")).toBe(String("🔴🔴🔴"));
}).toThrow("🔴🔴🔴");
expect(() => {
expect(new String("🟢🟢🟢")).toBe(String("🔴🔴🔴"));
}).toThrow("🔴🔴🔴");
expect(() => {
expect(String("🟢🟢🟢")).toBe(new String("🔴🔴🔴"));
}).toThrow("🔴🔴🔴");
expect(() => {
expect(new String("🟢🟢🟢")).toBe(new String("🔴🔴🔴"));
}).toThrow("🔴🔴🔴");
});
test("toHaveLength()", () => {