Skip to content

Commit

Permalink
Increase meaningfulness of tests.
Browse files Browse the repository at this point in the history
Use different top and left starting positions and move by different X and Y values for more meaningful assertions.
  • Loading branch information
lvonlanthen committed Jun 24, 2022
1 parent 615f9ce commit 6651bcd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/examples/Move.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default {
.absolute {
position: absolute;
margin: 0;
top: 100px;
left: 100px;
top: 10px;
left: 20px;
width: 1000px;
height: 1000px;
}
Expand Down
4 changes: 2 additions & 2 deletions src/examples/MoveOnMouseUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export default {
.absolute {
position: absolute;
margin: 0;
top: 100px;
left: 100px;
top: 10px;
left: 20px;
width: 1000px;
height: 1000px;
}
Expand Down
24 changes: 12 additions & 12 deletions tests/specs/move.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ describe('Drag drop', () => {

cy.findByTestId('draggable').should((target) => {
const { top, left } = target.offset()
expect(top).to.be.equal(100)
expect(left).to.be.equal(100)
expect(top).to.be.equal(10)
expect(left).to.be.equal(20)
})

cy.findByTestId('draggable').move({ deltaX: 100, deltaY: 100 })
cy.findByTestId('draggable').move({ deltaX: 30, deltaY: 40 })

cy.findByTestId('draggable').should('have.css', 'transform', 'matrix(1, 0, 0, 1, 100, 100)')
cy.findByTestId('draggable').should('have.css', 'transform', 'matrix(1, 0, 0, 1, 30, 40)')
cy.findByTestId('draggable').should((target) => {
const { top, left } = target.offset()
expect(top).to.be.equal(200)
expect(left).to.be.equal(200)
expect(top).to.be.equal(50)
expect(left).to.be.equal(50)
})
})

Expand All @@ -27,17 +27,17 @@ describe('Drag drop', () => {

cy.findByTestId('draggable').should((target) => {
const { top, left } = target.offset()
expect(top).to.be.equal(100)
expect(left).to.be.equal(100)
expect(top).to.be.equal(10)
expect(left).to.be.equal(20)
})

cy.findByTestId('draggable').move({ deltaX: 100, deltaY: 100 })
cy.findByTestId('draggable').move({ deltaX: 30, deltaY: 40 })

cy.findByTestId('draggable').should('have.css', 'transform', 'matrix(1, 0, 0, 1, 100, 100)')
cy.findByTestId('draggable').should('have.css', 'transform', 'matrix(1, 0, 0, 1, 30, 40)')
cy.findByTestId('draggable').should((target) => {
const { top, left } = target.offset()
expect(top).to.be.equal(200)
expect(left).to.be.equal(200)
expect(top).to.be.equal(50)
expect(left).to.be.equal(50)
})
})
})

0 comments on commit 6651bcd

Please sign in to comment.