Skip to content

Commit

Permalink
Merge pull request atom#19234 from atom/improve-flaky-test
Browse files Browse the repository at this point in the history
Disable external events from workspaceElement test
  • Loading branch information
rafeca authored Apr 30, 2019
2 parents 7e4dfa9 + 4e2e820 commit 2a7ddf0
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion spec/workspace-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,39 @@ describe('WorkspaceElement', () => {

describe('mousing over docks', () => {
let workspaceElement
let originalTimeout = jasmine.getEnv().defaultTimeoutInterval

beforeEach(() => {
workspaceElement = atom.workspace.getElement()
workspaceElement.style.width = '600px'
workspaceElement.style.height = '300px'
jasmine.attachToDOM(workspaceElement)

// To isolate this test from unintended events happening on the host machine,
// we remove any listener that could cause interferences.
window.removeEventListener(
'mousemove',
workspaceElement.handleEdgesMouseMove
)
workspaceElement.htmlElement.removeEventListener(
'mouseleave',
workspaceElement.handleCenterLeave
)

jasmine.getEnv().defaultTimeoutInterval = 10000
})

afterEach(() => {
jasmine.getEnv().defaultTimeoutInterval = originalTimeout

window.addEventListener(
'mousemove',
workspaceElement.handleEdgesMouseMove
)
workspaceElement.htmlElement.addEventListener(
'mouseleave',
workspaceElement.handleCenterLeave
)
})

it('shows the toggle button when the dock is open', async () => {
Expand Down Expand Up @@ -763,7 +790,8 @@ describe('WorkspaceElement', () => {
})

function moveMouse (coordinates) {
window.dispatchEvent(new MouseEvent('mousemove', coordinates))
// Simulate a mouse move event by calling the method that handles that event.
workspaceElement.updateHoveredDock({x: coordinates.clientX, y: coordinates.clientY})
advanceClock(100)
}

Expand Down

0 comments on commit 2a7ddf0

Please sign in to comment.