Atom packages can load cson grammars and TextMate packages can't

This commit is contained in:
Corey Johnson & Nathan Sobo
2013-03-21 13:25:52 -07:00
parent 1929899365
commit 0b719bfecf
20 changed files with 67 additions and 60 deletions

View File

@@ -76,3 +76,23 @@ describe "AtomPackage", ->
window.loadPackage("package-with-module")
expect(config.get('package-with-module.numbers.one')).toBe 1
expect(config.get('package-with-module.numbers.two')).toBe 2
describe "when the package has a grammars directory", ->
grammar = null
beforeEach ->
spyOn(syntax, 'addGrammar')
spyOn(syntax, 'addProperties')
window.loadPackage("package-with-a-cson-grammar")
expect(syntax.addGrammar).toHaveBeenCalled()
grammar = syntax.addGrammar.argsForCall[0][0]
it "loads the grammar and correctly parses a keyword", ->
expect(grammar.scopeName).toBe "source.alot"
{tokens} = grammar.tokenizeLine("this is alot of code")
expect(tokens[1]).toEqual value: "alot", scopes: ["source.alot", "keyword.alot"]
it "loads the properties included in the grammar files", ->
expect(syntax.addProperties).toHaveBeenCalled()
[selector, properties] = syntax.addProperties.argsForCall[0]
expect(selector).toBe ".source.alot"
expect(properties).toEqual {editor: increaseIndentPattern: '^a'}

View File

@@ -258,14 +258,3 @@ describe "TextMateGrammar", ->
{tokens, ruleStack} = grammar.tokenizeLine("if(1){if(1){m()}}")
expect(tokens[5]).toEqual value: "if", scopes: ["source.c", "meta.block.c", "keyword.control.c"]
expect(tokens[10]).toEqual value: "m", scopes: ["source.c", "meta.block.c", "meta.block.c", "meta.function-call.c", "support.function.any-method.c"]
describe "when the grammar is CSON", ->
it "loads the grammar and correctly parses a keyword", ->
spyOn(syntax, 'addGrammar')
pack = new TextMatePackage(project.resolve("packages/package-with-a-cson-grammar.tmbundle"))
pack.load()
grammar = pack.grammars[0]
expect(grammar).toBeTruthy()
expect(grammar.scopeName).toBe "source.alot"
{tokens} = grammar.tokenizeLine("this is alot of code")
expect(tokens[1]).toEqual value: "alot", scopes: ["source.alot", "keyword.alot"]