Skip to content

Commit

Permalink
feat: add full constraint test
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianCraig committed Feb 25, 2020
1 parent 9bf0384 commit 3b16d54
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/constraints/constraint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,50 @@ describe("constraint resolving tests", () => {
expect(constraint.resolved).toBe(Boolean(true));
expect(testedComponent.positions[Side.top]).toBe(10);
});

test("a full constrainted Component", () => {
const testedComponent = NewComponent("nameX");
const parent = ParentComponent();
const constraintTop: ConstraintInstance = {
fromInstance: testedComponent,
fromSide: Side.top,
toInstance: parent,
toSide: Side.top,
resolved: Boolean(false),
distance: 10
};

const constraintRight = {
...constraintTop,
fromSide: Side.right,
toSide: Side.right,
distance: -10
};

const constraintBottom = {
...constraintTop,
fromSide: Side.bottom,
toSide: Side.bottom,
distance: -10
};

const constraintLeft = {
...constraintTop,
fromSide: Side.left,
toSide: Side.left,
distance: 10
};

ResolveConstraint(constraintTop);
ResolveConstraint(constraintRight);
ResolveConstraint(constraintBottom);
ResolveConstraint(constraintLeft);

expect(testedComponent.positions).toStrictEqual({
[Side.top]: 10,
[Side.right]: 90,
[Side.bottom]: 90,
[Side.left]: 10
});
});
});

0 comments on commit 3b16d54

Please sign in to comment.