Mock clock and animation frames in TextEditorComponent specs

This commit is contained in:
Nathan Sobo 2016-08-11 07:55:32 -06:00
parent 67410f3f18
commit ced2174b5a
4 changed files with 642 additions and 652 deletions

View File

@ -19,9 +19,7 @@ exports.afterEach = (fn) ->
waitsForPromise = (fn) ->
promise = fn()
# This timeout is 3 minutes. We need to bump it back down once we fix backgrounding
# of the renderer process on CI. See https://github.com/atom/electron/issues/4317
waitsFor 'spec promise to resolve', 3 * 60 * 1000, (done) ->
waitsFor 'spec promise to resolve', 5000, (done) ->
promise.then(
done,
(error) ->

View File

@ -169,6 +169,13 @@ jasmine.useRealClock = ->
jasmine.unspy(window, 'clearTimeout')
jasmine.unspy(_._, 'now')
# The clock is halfway mocked now in a sad and terrible way... only setTimeout
# and clearTimeout are included. This method will also include setInterval. We
# would do this everywhere if didn't cause us to break a bunch of package tests.
jasmine.useMockClock = ->
spyOn(window, 'setInterval').andCallFake(fakeSetInterval)
spyOn(window, 'clearInterval').andCallFake(fakeClearInterval)
addCustomMatchers = (spec) ->
spec.addMatchers
toBeInstanceOf: (expected) ->
@ -242,7 +249,7 @@ window.resetTimeouts = ->
window.timeouts = []
window.intervalTimeouts = {}
window.fakeSetTimeout = (callback, ms) ->
window.fakeSetTimeout = (callback, ms=0) ->
id = ++window.timeoutCount
window.timeouts.push([id, window.now + ms, callback])
id

File diff suppressed because it is too large Load Diff

View File

@ -822,7 +822,6 @@ class TextEditorComponent
sampleBackgroundColors: (suppressUpdate) ->
{backgroundColor} = getComputedStyle(@hostElement)
@presenter.setBackgroundColor(backgroundColor)
lineNumberGutter = @gutterContainerComponent?.getLineNumberGutterComponent()