Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Commit

Permalink
chore: rm unused event-positions (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwendt authored Nov 23, 2021
1 parent 03ac028 commit cf695bd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 43 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"author": "Felix Becker <[email protected]>",
"dependencies": {
"@sourcegraph/event-positions": "^1.0.4",
"@sourcegraph/extension-api-types": "^2.1.0",
"lodash": "^4.17.10",
"rxjs": "6.6.3",
Expand Down
31 changes: 0 additions & 31 deletions src/testutils/mouse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CharacterPositions } from '@sourcegraph/event-positions'
import { Position } from '@sourcegraph/extension-api-types'
import { convertNode } from '../token_position'
import { CodeViewProps } from './dom'
Expand Down Expand Up @@ -68,33 +67,3 @@ export const dispatchMouseEventAtPositionImpure = (
characterOffset += value.length
}
}

/**
* Dispatch a click event at a position in the code view.
*
* @param codeViewProps the CodeViewProps from the generated test cases
* @param position the 0-indexed position to click
*/
export const clickPosition = ({ codeView, getCodeElementFromLineNumber }: CodeViewProps, position: Position): void => {
const line = getCodeElementFromLineNumber(codeView, position.line)
if (!line) {
throw new Error(invalidPosition(position, 'Line not found'))
}

const positions = new CharacterPositions(line)

const left = positions.getCharacterOffset(position.character, line, true)
const right = positions.getCharacterOffset(position.character, line, false)
const width = right - left

const rect = line.getBoundingClientRect()
const top = rect.top
const height = rect.height

const event = createMouseEvent('click', {
x: left + width / 2,
y: top + height / 2,
})

line.dispatchEvent(event)
}
13 changes: 2 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,7 @@
eslint-plugin-react-hooks "^4.0.0"
eslint-plugin-rxjs "^0.0.2-beta.20"

"@sourcegraph/event-positions@^1.0.4":
version "1.0.4"
resolved "https://registry.npmjs.org/@sourcegraph/event-positions/-/event-positions-1.0.4.tgz#031541374b725cfb0cbefaa07add020b1a119a60"
integrity sha512-mrWIEpC9UuAZwExMQlRfLaLLwC9x8WQMAOEYFHGEdXCzXEHqaZu22aR8PtrQEMtwia6eIzvZl6uYp0gDDGLo2g==
dependencies:
"@sourcegraph/extension-api-types" "^2.0.0"
lodash "^4.17.10"
rxjs "^6.3.2"

"@sourcegraph/extension-api-types@^2.0.0", "@sourcegraph/extension-api-types@^2.1.0":
"@sourcegraph/extension-api-types@^2.1.0":
version "2.1.0"
resolved "https://registry.npmjs.org/@sourcegraph/extension-api-types/-/extension-api-types-2.1.0.tgz#dcc81eba70371c9aabc7333361f5e1ed63e7c91e"
integrity sha512-KWxkyphmlwam8kfYPSmoitKQRMGQCsr1ZRmNZgijT7ABKaVyk/+I5ezt2J213tM04Hi0vyg4L7iH1VCkNvm2Jw==
Expand Down Expand Up @@ -7694,7 +7685,7 @@ run-queue@^1.0.0, run-queue@^1.0.3:
dependencies:
aproba "^1.1.1"

[email protected], rxjs@^6.3.2:
[email protected]:
version "6.6.3"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.3.tgz#8ca84635c4daa900c0d3967a6ee7ac60271ee552"
integrity sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==
Expand Down

0 comments on commit cf695bd

Please sign in to comment.