Skip to content

Commit

Permalink
@cucumber/suggest: Add StepDocument#expression (#1757)
Browse files Browse the repository at this point in the history
* @cucumber/suggest: Add StepDocument#expression

* Fix compilation errors
  • Loading branch information
aslakhellesoy authored Oct 9, 2021
1 parent 06d5973 commit ccb6867
Show file tree
Hide file tree
Showing 12 changed files with 2,191 additions and 3,100 deletions.
2 changes: 2 additions & 0 deletions language-server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

* Upgrade to `@cucumber/cucumber-expressions 13.0.1`

### Deprecated

### Removed
Expand Down
2 changes: 1 addition & 1 deletion language-server/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cucumber/language-server",
"version": "0.1.0",
"version": "0.2.0",
"description": "Cucumber Language Server",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions language-server/javascript/test/CucumberInfoStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('CucumberInfoStream', () => {
},
})
)
const expectedStepDocuments: StepDocument[] = [
const expectedStepDocuments: Partial<StepDocument>[] = [
{
segments: ['I select the ', ['2nd'], ' snippet'],
suggestion: 'I select the {ordinal} snippet',
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('CucumberInfoStream', () => {
suggestion: 'the suggestions should be:',
},
]
assert.deepStrictEqual(cucumberInfo.stepDocuments, expectedStepDocuments)
assert.deepStrictEqual(cucumberInfo.stepDocuments.map(d => ({segments: d.segments, suggestion: d.suggestion})), expectedStepDocuments)

const expectedExpressionSources = [
'the following Gherkin step texts exist:',
Expand Down
24 changes: 14 additions & 10 deletions language-service/javascript/test/getGherkinCompletionItems.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ import { CompletionItem, CompletionItemKind, InsertTextFormat } from 'vscode-lan
import assert from 'assert'
import { StepDocument, bruteForceIndex } from '@cucumber/suggest'
import { getGherkinCompletionItems } from '../src'

const doc1: StepDocument = {
suggestion: 'I have {int} cukes in my belly',
segments: ['I have ', ['42', '98'], ' cukes in my belly'],
}
const doc2: StepDocument = {
suggestion: 'I am a teapot',
segments: ['I am a teapot'],
}
const index = bruteForceIndex([doc1, doc2])
import { ExpressionFactory, ParameterTypeRegistry } from '@cucumber/cucumber-expressions'

describe('getGherkinCompletionItems', () => {
it('completes with step text', () => {
const ef = new ExpressionFactory(new ParameterTypeRegistry())
const doc1: StepDocument = {
suggestion: 'I have {int} cukes in my belly',
segments: ['I have ', ['42', '98'], ' cukes in my belly'],
expression: ef.createExpression('I have {int} cukes in my belly')
}
const doc2: StepDocument = {
suggestion: 'I am a teapot',
segments: ['I am a teapot'],
expression: ef.createExpression('I am a teapot')
}

const index = bruteForceIndex([doc1, doc2])
const gherkinSource = `Feature: Hello
Scenario: World
Given cukes
Expand Down
Loading

0 comments on commit ccb6867

Please sign in to comment.