Skip to content

Commit

Permalink
chore: add class.inheritance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Aug 14, 2020
1 parent 58f4491 commit 4fc79fd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/suites/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,41 @@ export default function (klona) {
assert.equal(output.val, 42);
});

Classes('inheritance', () => {
class Animal {
constructor() {
this.cute = true;
}
get carbon() {
return true;
}
}

class Dog extends Animal {
constructor(name) {
super();
this.name = name;
}
bark() {
console.log('woof');
}
}

const input = new Dog('spot');
const output = klona(input);

assert.deepEqual(input, output);
assert.deepEqual(input.name, output.name);
assert.equal(output instanceof Animal, true);
assert.deepEqual(output.constructor, Dog);
assert.deepEqual(output.__proto__, {});
assert.equal(output.carbon, true);

assert.deepStrictEqual(
Object.getOwnPropertyDescriptors(input),
Object.getOwnPropertyDescriptors(output),
);
});

Classes.run();
}

0 comments on commit 4fc79fd

Please sign in to comment.