2020-07-05 17:26:26 -07:00
|
|
|
test("basic functionality", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
function Foo() {
|
|
|
|
|
this.x = 123;
|
|
|
|
|
}
|
2020-03-28 19:48:12 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
const foo = new Foo();
|
|
|
|
|
expect(foo instanceof Foo).toBeTrue();
|
2020-07-05 17:26:26 -07:00
|
|
|
});
|
2020-03-28 19:48:12 +01:00
|
|
|
|
2020-07-05 17:26:26 -07:00
|
|
|
test("derived ES5 classes", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
function Base() {
|
|
|
|
|
this.is_base = true;
|
|
|
|
|
}
|
2020-03-28 19:48:12 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
function Derived() {
|
|
|
|
|
this.is_derived = true;
|
|
|
|
|
}
|
2020-03-28 19:48:12 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
Object.setPrototypeOf(Derived.prototype, Base.prototype);
|
2020-03-28 19:48:12 +01:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
const d = new Derived();
|
|
|
|
|
expect(d instanceof Derived).toBeTrue();
|
|
|
|
|
expect(d instanceof Base).toBeTrue();
|
2020-07-05 17:26:26 -07:00
|
|
|
});
|