1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

LibJS: Convert all remaining non-Array tests to the new system :)

This commit is contained in:
Matthew Olsson 2020-07-05 17:26:26 -07:00 committed by Andreas Kling
parent 918f4affd5
commit 15de2eda2b
72 changed files with 2394 additions and 1998 deletions

View file

@ -0,0 +1,35 @@
test("extending function", () => {
class A extends function () {
this.foo = 10;
} {}
expect(new A().foo).toBe(10);
});
test("extending null", () => {
class A extends null {}
expect(Object.getPrototypeOf(A.prototype)).toBeNull();
expect(() => {
new A();
}).toThrowWithMessage(ReferenceError, "|this| has not been initialized");
});
test("extending String", () => {
class MyString extends String {}
const ms = new MyString("abc");
expect(ms).toBeInstanceOf(MyString);
expect(ms).toBeInstanceOf(String);
expect(ms.charAt(1)).toBe("b");
class MyString2 extends MyString {
charAt(i) {
return `#${super.charAt(i)}`;
}
}
const ms2 = new MyString2("abc");
expect(ms2.charAt(1)).toBe("#b");
});