Move grammar-used spec to workspace-spec

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2016-07-26 15:38:53 -07:00
committed by Nathan Sobo
parent d203610986
commit caab1dda63
2 changed files with 29 additions and 54 deletions

View File

@@ -736,60 +736,6 @@ describe "TokenizedBuffer", ->
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens.length).toBe 1
expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0].value).toBe 'c'
describe 'when a file is opened', ->
[registration, editor, called] = []
beforeEach ->
runs ->
called = false
registration = atom.packages.onDidTriggerActivationHook('language-javascript:grammar-used', -> called = true)
waitsForPromise ->
atom.workspace.open('sample.js', autoIndent: false).then (o) ->
editor = o
waitsForPromise ->
atom.packages.activatePackage('language-javascript')
afterEach: ->
registration?.dispose?()
atom.packages.deactivatePackages()
atom.packages.unloadPackages()
it 'triggers the grammar-used hook', ->
waitsFor ->
called is true
runs ->
expect(called).toBe true
describe 'when changing the grammar of an open file', ->
[coffeeRegistration, coffeeCalled] = []
beforeEach ->
coffeeCalled = false
coffeeRegistration = atom.packages.onDidTriggerActivationHook('language-coffee-script:grammar-used', -> coffeeCalled = true)
waitsForPromise ->
atom.packages.activatePackage('language-coffee-script')
afterEach ->
coffeeRegistration?.dispose()
it 'triggers the grammar-used hook', ->
waitsFor ->
called is true
runs ->
expect(called).toBe true
expect(coffeeCalled).toBe false
editor.setGrammar(atom.grammars.selectGrammar('.coffee'))
waitsFor ->
coffeeCalled is true
runs ->
expect(coffeeCalled).toBe true
describe "text decoration layer API", ->
describe "iterator", ->
it "iterates over the syntactic scope boundaries", ->

View File

@@ -652,6 +652,35 @@ describe "Workspace", ->
expect(rightPane.getPendingItem()).toBe editor2
expect(rightPane.destroyed.callCount).toBe 0
describe 'the grammar-used hook', ->
it 'fires when opening a file or changing the grammar of an open file', ->
editor = null
javascriptGrammarUsed = false
coffeescriptGrammarUsed = false
waitsForPromise ->
atom.packages.activate()
runs ->
atom.packages.onDidTriggerActivationHook 'language-javascript:grammar-used', -> javascriptGrammarUsed = true
atom.packages.onDidTriggerActivationHook 'language-coffee-script:grammar-used', -> coffeescriptGrammarUsed = true
waitsForPromise ->
atom.workspace.open('sample.js', autoIndent: false).then (o) -> editor = o
waitsForPromise ->
atom.packages.activatePackage('language-javascript')
waitsFor -> javascriptGrammarUsed
waitsForPromise ->
atom.packages.activatePackage('language-coffee-script')
runs ->
editor.setGrammar(atom.grammars.selectGrammar('.coffee'))
waitsFor -> coffeescriptGrammarUsed
describe "::reopenItem()", ->
it "opens the uri associated with the last closed pane that isn't currently open", ->
pane = workspace.getActivePane()