mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
There's a slight wrinkle in this commit… TextMate grammars sometimes store the `foldStopMarker` directly in the grammar, rather than storing it in a separate scoped preferences file like the other settings. So we have to scan through grammars looking for those that have the fold end marker and make a scoped property for that grammar's scope.
37 lines
1.8 KiB
CoffeeScript
37 lines
1.8 KiB
CoffeeScript
fs = require('fs')
|
|
TextMateBundle = require 'text-mate-bundle'
|
|
|
|
describe "TextMateBundle", ->
|
|
describe ".getPreferencesByScopeSelector()", ->
|
|
it "logs warning, but does not raise errors if a preference can't be parsed", ->
|
|
bundlePath = fs.join(require.resolve('fixtures'), "test.tmbundle")
|
|
spyOn(console, 'warn')
|
|
bundle = new TextMateBundle(bundlePath)
|
|
expect(-> bundle.getPreferencesByScopeSelector()).not.toThrow()
|
|
expect(console.warn).toHaveBeenCalled()
|
|
|
|
describe ".constructor(bundlePath)", ->
|
|
it "logs warning, but does not raise errors if a grammar can't be parsed", ->
|
|
bundlePath = fs.join(require.resolve('fixtures'), "test.tmbundle")
|
|
spyOn(console, 'warn')
|
|
expect(-> new TextMateBundle(bundlePath)).not.toThrow()
|
|
expect(console.warn).toHaveBeenCalled()
|
|
|
|
describe ".grammarForFilePath(filePath)", ->
|
|
it "uses the filePath's extension to load the correct grammar", ->
|
|
expect(TextMateBundle.grammarForFilePath("file.js").name).toBe "JavaScript"
|
|
|
|
it "uses the filePath's base name if there is no extension", ->
|
|
expect(TextMateBundle.grammarForFilePath("Rakefile").name).toBe "Ruby"
|
|
|
|
it "uses the filePath's shebang line if the grammar cannot be determined by the extension or basename", ->
|
|
filePath = require.resolve("fixtures/shebang")
|
|
expect(TextMateBundle.grammarForFilePath(filePath).name).toBe "Ruby"
|
|
|
|
it "uses the grammar's fileType as a suffix of the full filePath if the grammar cannot be determined by shebang line", ->
|
|
expect(TextMateBundle.grammarForFilePath("/tmp/.git/config").name).toBe "Git Config"
|
|
|
|
it "uses plain text if no grammar can be found", ->
|
|
filePath = require.resolve("this-is-not-a-real-file")
|
|
expect(TextMateBundle.grammarForFilePath(filePath).name).toBe "Plain Text"
|