Skip to content

Commit

Permalink
test(modifiers/aspectRatio): add test for corners with submodifier
Browse files Browse the repository at this point in the history
Re: #963
  • Loading branch information
taye committed Jun 11, 2022
1 parent 64fcbe1 commit 95a28a9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/@interactjs/modifiers/aspectRatio.spec.ts
Expand Up @@ -43,7 +43,7 @@ test('modifiers/aspectRatio', () => {
options.equalDelta = false
options.ratio = 2
downStartMoveUp({ x: -5, y: 2, edges: { left: true } })
// equalDelta: false, ratio: 2, edges: { left: true }
// equalDelta: false, ratio: 2, edges: left
expect(lastRect).toEqual(ltrbwh(-5, 12.5, 10, 20, 15, 7.5))

// combine with restrictSize
Expand All @@ -54,14 +54,24 @@ test('modifiers/aspectRatio', () => {
]
options.equalDelta = false
options.ratio = 2

downStartMoveUp({ x: 20, y: 0, edges: { right: true } })
// restrictSize with critical prmary edge
// restrictSize with critical primary edge
expect(lastRect).toEqual(ltrbwh(0, 0, 20, 10, 20, 10))

downStartMoveUp({ x: 20, y: 20, edges: { bottom: true } })
// restrictSize with critical secondary edge
expect(lastRect).toEqual(ltrbwh(0, 0, 20, 10, 20, 10))

options.ratio = 0.5
downStartMoveUp({ x: 5, y: -5, edges: { left: true, bottom: true } })
// equalDelta: false, ratio: 2, edges: left & bottom
expect(lastRect).toEqual(ltrbwh(5, 0, 10, 10, 5, 10))

downStartMoveUp({ x: -5, y: -5, edges: { right: true, top: true } })
// equalDelta: false, ratio: 2, edges: right & top
expect(lastRect).toEqual(ltrbwh(0, 10, 5, 20, 5, 10))

function downStartMoveUp ({ x, y, edges }: { x: number, y: number, edges: EdgeOptions }) {
coords.timeStamp = 0
interaction.stop()
Expand Down

0 comments on commit 95a28a9

Please sign in to comment.