mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 16:08:24 +03:00
Save state on mousedown or keypress events (debounce 1s). Tests WIP
This commit is contained in:
parent
39cb52c224
commit
df83078d74
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user