ladybird/Userland/Libraries/LibJS/Tests/builtins/String/String.js
Timothy Flynn a2e734d202 LibJS: Report string length as the code point length, not byte length
For example, U+180E is 3 bytes, but should have a string length of 1.
2021-07-17 16:59:59 +01:00

16 lines
456 B
JavaScript

test("constructor properties", () => {
expect(String).toHaveLength(1);
expect(String.name).toBe("String");
});
test("typeof", () => {
expect(typeof String()).toBe("string");
expect(typeof new String()).toBe("object");
});
test("length", () => {
expect(new String().length).toBe(0);
expect(new String("a").length).toBe(1);
expect(new String("\u180E").length).toBe(1);
expect(new String("\uDBFF\uDFFF").length).toBe(2);
});