Skip to content

Commit

Permalink
test: circularity
Browse files Browse the repository at this point in the history
  • Loading branch information
slikts committed Feb 24, 2020
1 parent 1d6a1c6 commit 1f8a59d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/ValueObject.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueObject } from '../src/tuplerone';
import { ValueObject, shallow } from '../src/tuplerone';

describe(ValueObject.name, () => {
it('constructs', () => {
Expand Down Expand Up @@ -39,4 +39,13 @@ describe(ValueObject.name, () => {
expect(() => ValueObject(null)).not.toThrow();
expect(() => ValueObject(undefined)).not.toThrow();
});

it('can be short-circuited if circular', () => {
const a: any = {};
const b = { a };
a.b = b;
expect(() => ValueObject(a)).toThrow();
a[shallow] = true;
expect(() => ValueObject(a)).not.toThrow();
});
});

0 comments on commit 1f8a59d

Please sign in to comment.