Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add regression tests for tab stops at ends of snippets #289

Merged
merged 3 commits into from Apr 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions spec/snippets-spec.coffee
Expand Up @@ -165,6 +165,14 @@ describe "Snippets extension", ->
${2:placeholder ending second line}
"""

"tab stops at the ends of snippets":
prefix: "t6b"
body: "$1expanded$0"

"tab stops at the ends of snippets - alternative":
prefix: "t6c"
body: "$0expanded$1"

"contains empty lines":
prefix: "t7"
body: """
Expand Down Expand Up @@ -591,6 +599,28 @@ describe "Snippets extension", ->
simulateTabKeyEvent()
expect(editor.lineTextForBufferRow(0)).toBe "first line"

it "does not remember the tab stops when the whole snippet has been undone (regression)", ->
editor.insertText 't6b\n'
editor.setCursorBufferPosition [0, 3]
simulateTabKeyEvent()
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
editor.undo()
expect(editor.lineTextForBufferRow(0)).toBe "t6b"
simulateTabKeyEvent()
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
expect(editor.getCursorBufferPosition()).toEqual([0, 0])

it "does not remember the tab stops when the whole snippet has been undone (regression, alternative version)", ->
editor.insertText 't6c\n'
editor.setCursorBufferPosition [0, 3]
simulateTabKeyEvent()
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
editor.undo()
expect(editor.lineTextForBufferRow(0)).toBe "t6c"
simulateTabKeyEvent()
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
expect(editor.getCursorBufferPosition()).toEqual([0, 8])

describe "when the prefix contains non-word characters", ->
it "selects the non-word characters as part of the prefix", ->
editor.insertText("@unique")
Expand Down