Skip to content

Commit

Permalink
Add keyword tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkadwill committed Feb 6, 2016
1 parent ed9f3d6 commit b7799a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ module.exports =
@getCompletions(line, file)

getCompletions: (line, file) ->
completions = []
match = PROPERTY_PREFIX_PATTERN.exec(line)?[1]
return completions unless match
return [] unless @matchCucumberKeyword(line)

results = []
regex = /(Given|And|When|Then)(.*)/g
Expand All @@ -34,6 +32,9 @@ module.exports =

return results

matchCucumberKeyword: (line) ->
PROPERTY_PREFIX_PATTERN.exec(line)?[1] != null

rootDirectory: ->
atom.project.rootDirectories[0].path

Expand Down
21 changes: 21 additions & 0 deletions spec/provider-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@ describe "provider model", ->
describe "rootDirectory", ->
it "gets the root directory", ->
expect(model.rootDirectory()).toEqual atom.project.rootDirectories[0].path

describe "matchCucumberKeyword", ->
it "matches Given keyword", ->
line = "Given something"
expect(model.matchCucumberKeyword(line)).toEqual true

it "matches And keyword", ->
line = "And something"
expect(model.matchCucumberKeyword(line)).toEqual true

it "matches When keyword", ->
line = "When something"
expect(model.matchCucumberKeyword(line)).toEqual true

it "matches Then keyword", ->
line = "Then something"
expect(model.matchCucumberKeyword(line)).toEqual true

it "doesn't match if there are no keyworks", ->
line = "I something"
expect(model.matchCucumberKeyword(line)).toEqual true

0 comments on commit b7799a2

Please sign in to comment.