formats.exposed/test/common/getOwn.test.ts

21 lines
523 B
TypeScript
Raw Normal View History

import { assertEquals } from "assert";
import getOwn from "../../public/common/getOwn.js";
class Person {
constructor(public age: number) {}
getAge() {
return this.age;
}
}
const person = new Person(10);
Deno.test('fetches "own" properties', () => {
assertEquals(getOwn(person, "age"), 10);
});
Deno.test("ignores inherited properties", () => {
assertEquals(getOwn(person, "getAge"), undefined);
// deno-lint-ignore no-explicit-any
assertEquals(getOwn(person, "hasOwnProperty" as any), undefined);
});