Load snippets from .atom/snippets when snippets extension is activated

This commit is contained in:
David Graham & Nathan Sobo
2012-06-20 11:49:29 -06:00
parent dc6c0a3e35
commit d992458c8c
2 changed files with 35 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ RootView = require 'root-view'
Buffer = require 'buffer'
Editor = require 'editor'
_ = require 'underscore'
fs = require 'fs'
fdescribe "Snippets extension", ->
[buffer, editor] = []
@@ -28,6 +29,21 @@ fdescribe "Snippets extension", ->
expect(buffer.lineForRow(0)).toBe "this is a testvar quicksort = function () {"
expect(editor.getCursorScreenPosition()).toEqual [0, 14]
describe ".loadSnippetsFile(path)", ->
it "loads the snippets in the given file", ->
spyOn(fs, 'read').andReturn """
snippet t1 "Test snippet 1"
this is a test 1
endsnippet
"""
Snippets.loadSnippetsFile('/tmp/foo/js.snippets')
expect(fs.read).toHaveBeenCalledWith('/tmp/foo/js.snippets')
editor.insertText("t1")
editor.trigger 'tab'
expect(buffer.lineForRow(0)).toBe "this is a test 1var quicksort = function () {"
describe "Snippets parser", ->
it "can parse multiple snippets", ->
snippets = Snippets.snippetsParser.parse """