Skip to content

Commit

Permalink
Tests: Tests for diamond dependency graph
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed May 21, 2020
1 parent 09fa7f5 commit 3759c6e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/extend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,41 @@ describe('`.extend()`', () => {
expect(instance.getVersion()).toBe('1.0.0');
});
});

describe('with diamond dependency graph', () => {
it('created by 2 calls to extend()', () => {
const extension1 = new Extension(InClass => class extends InClass {
constructor() {
super();
this.count = (this.count || 0) + 1;
}
});
const extension2 = new Extension([extension1], InClass => class extends InClass {});
const extension3 = new Extension([extension1], InClass => class extends InClass {});
const SubClass = Class.extend(extension2)
.extend(extension3);
const instance = new SubClass();
expect(instance.count).toBe(1);
});

it('created within extension', () => {
const extension1 = new Extension(InClass => class extends InClass {
constructor() {
super();
this.count = (this.count || 0) + 1;
}
});
const extension2 = new Extension([extension1], InClass => class extends InClass {});
const extension3 = new Extension([extension1], InClass => class extends InClass {});
const extension4 = new Extension(
[extension2, extension3],
InClass => class extends InClass {}
);
const SubClass = Class.extend(extension4);
const instance = new SubClass();
expect(instance.count).toBe(1);
});
});
});

describe('throws if extend with different version of same extension', () => {
Expand Down

0 comments on commit 3759c6e

Please sign in to comment.