mirror of
https://github.com/atom/atom.git
synced 2026-01-27 07:47:58 -05:00
Save state on mousedown or keypress events (debounce 1s). Tests WIP
This commit is contained in:
@@ -174,6 +174,19 @@ describe "AtomEnvironment", ->
|
||||
atom.loadStateSync()
|
||||
expect(atom.state.stuff).toBe("cool")
|
||||
|
||||
it "saves state on keypress and mousedown events", ->
|
||||
spyOn(atom, 'saveStateSync')
|
||||
|
||||
keypress = new KeyboardEvent('keypress')
|
||||
atom.document.dispatchEvent(keypress)
|
||||
advanceClock 1100
|
||||
expect(atom.saveStateSync).toHaveBeenCalled()
|
||||
|
||||
mousedown = new MouseEvent('mousedown')
|
||||
atom.document.dispatchEvent(mousedown)
|
||||
advanceClock 1100
|
||||
expect(atom.saveStateSync).toHaveBeenCalled()
|
||||
|
||||
describe "openInitialEmptyEditorIfNecessary", ->
|
||||
describe "when there are no paths set", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -119,6 +119,9 @@ class AtomEnvironment extends Model
|
||||
constructor: (params={}) ->
|
||||
{@blobStore, @applicationDelegate, @window, @document, configDirPath, @enablePersistence, onlyLoadBaseStyleSheets} = params
|
||||
|
||||
@document.addEventListener('mousedown', _.debounce(@saveStateSync.bind(this), 1000), true)
|
||||
@document.addEventListener('keypress', _.debounce(@saveStateSync.bind(this), 1000), true)
|
||||
|
||||
@state = {version: @constructor.version}
|
||||
|
||||
@loadTime = null
|
||||
|
||||
Reference in New Issue
Block a user