Terminate worker when all snippets have been loaded

This commit is contained in:
Kevin Sawicki
2013-01-27 22:26:45 -08:00
parent a89e1fae11
commit 75da205b0a
3 changed files with 16 additions and 0 deletions

View File

@@ -255,6 +255,18 @@ describe "Snippets extension", ->
expect(console.warn).toHaveBeenCalled()
expect(console.warn.calls.length).toBe 1
it "terminates the worker when loading completes", ->
jasmine.unspy(LoadSnippetsTask.prototype, 'loadAtomSnippets')
spyOn(Worker.prototype, 'terminate').andCallThrough()
snippets.loaded = false
snippets.loadAll()
waitsFor "all snippets to load", 5000, -> snippets.loaded
runs ->
expect(Worker.prototype.terminate).toHaveBeenCalled()
expect(Worker.prototype.terminate.calls.length).toBe 1
describe "Snippet body parser", ->
it "breaks a snippet body into lines, with each line containing tab stops at the appropriate position", ->
bodyTree = snippets.getBodyParser().parse """

View File

@@ -13,6 +13,7 @@ class LoadSnippetsTask extends Task
loadNextPackageSnippets: ->
unless @packages.length
@terminate()
@snippets.loaded = true
return

View File

@@ -30,3 +30,6 @@ class Task
postMessage: (data) ->
@worker.postMessage(data)
terminate: ->
@worker.terminate()