From dd69abbdfe22ac199f6c031f3b6c9145bbdfcd6e Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 20 Jun 2012 12:20:37 -0600 Subject: [PATCH] Add test case for non-matching prefix causing a regular tab to be inserted --- spec/extensions/snippets-spec.coffee | 36 +++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/spec/extensions/snippets-spec.coffee b/spec/extensions/snippets-spec.coffee index 759b60a2e..f0bd2e959 100644 --- a/spec/extensions/snippets-spec.coffee +++ b/spec/extensions/snippets-spec.coffee @@ -15,19 +15,33 @@ fdescribe "Snippets extension", -> rootView.simulateDomAttachment() describe "when 'tab' is triggered on the editor", -> - describe "when the letters preceding the cursor are registered as a global extension", -> - it "replaces the prefix with the snippet text", -> - Snippets.evalSnippets 'js', """ - snippet te "Test snippet description" - this is a test - endsnippet - """ - editor.insertText("te") - expect(editor.getCursorScreenPosition()).toEqual [0, 2] + beforeEach -> + Snippets.evalSnippets 'js', """ + snippet te "Test snippet description" + this is a test + endsnippet + """ + describe "when the letters preceding the cursor trigger a snippet", -> + describe "when the snippet contains no tab stops", -> + it "replaces the prefix with the snippet text and places the cursor at its end", -> + editor.insertText("te") + expect(editor.getCursorScreenPosition()).toEqual [0, 2] + + editor.trigger 'tab' + expect(buffer.lineForRow(0)).toBe "this is a testvar quicksort = function () {" + expect(editor.getCursorScreenPosition()).toEqual [0, 14] + + describe "when the snippet contains tab stops", -> + + + describe "when the letters preceding the cursor don't match a snippet", -> + it "inserts a tab as normal", -> + editor.insertText("xte") + expect(editor.getCursorScreenPosition()).toEqual [0, 3] editor.trigger 'tab' - expect(buffer.lineForRow(0)).toBe "this is a testvar quicksort = function () {" - expect(editor.getCursorScreenPosition()).toEqual [0, 14] + expect(buffer.lineForRow(0)).toBe "xte var quicksort = function () {" + expect(editor.getCursorScreenPosition()).toEqual [0, 5] describe ".loadSnippetsFile(path)", -> it "loads the snippets in the given file", ->