Skip to content

Commit

Permalink
chore: add Classes test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Jul 15, 2020
1 parent 2dc8be3 commit 45c6194
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,70 @@ Functions('Functions', () => {
Functions.run();

// ---

const Classes = suite('class');

Classes('class', () => {
class Foobar {}
same(new Foobar, new Foobar);
});

// @see https://github.com/lukeed/klona/issues/14
Classes('prototype', () => {
function Test () {}
Test.prototype.val = 42;

same(new Test, new Test);
});

Classes('constructor properties', () => {
function Test (num) {
this.value = num;
}

Test.prototype.val = 42;

same(new Test(123), new Test(123));
different(new Test(0), new Test(123));
});

Classes('constructor properties :: class', () => {
class Test {
constructor(num) {
this.value = num;
}
}

same(new Test, new Test);
same(new Test(123), new Test(123));
different(new Test, new Test(123));
});

Classes('constructor properties :: defaults', () => {
class Test {
constructor(num = 123) {
this.value = num;
}
}

same(new Test(456), new Test(456));
same(new Test(123), new Test);
});

Classes('accessors', () => {
class Test {
get val() {
return 42;
}
}

same(new Test, new Test);
});

Classes.run();

// ---

const kitchen = suite('kitchen');

kitchen('kitchen sink', () => {
Expand Down

0 comments on commit 45c6194

Please sign in to comment.