This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7cfd9e
commit 6e1878f
Showing
10 changed files
with
106 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {io} from "cucumber-messages/src/cucumber-messages"; | ||
import * as Stream from "stream"; | ||
import Source = io.cucumber.messages.Source; | ||
|
||
export interface IGherkinOptions { | ||
includeSource: boolean, | ||
includeGherkinDocument: boolean, | ||
includePickles: boolean, | ||
} | ||
|
||
export function fromPaths(args: string[], options?: IGherkinOptions): Stream.Readable; | ||
export function fromSources(args: Source[], options?: IGherkinOptions): Stream.Readable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-env mocha */ | ||
import * as assert from 'assert' | ||
import * as gherkin from "../src"; | ||
import {Readable} from "stream"; | ||
import {io} from "cucumber-messages"; | ||
import Wrapper = io.cucumber.messages.Wrapper; | ||
import Source = io.cucumber.messages.Source; | ||
import Media = io.cucumber.messages.Media; | ||
|
||
describe('gherkin', () => { | ||
it('parses gherkin from the file system', async () => { | ||
const wrappers = await streamToArray( | ||
gherkin.fromPaths(['testdata/good/minimal.feature']) | ||
) | ||
assert.strictEqual(wrappers.length, 3) | ||
}) | ||
|
||
it('parses gherkin from STDIN', async () => { | ||
const source = Source.fromObject({ | ||
uri: 'test.feature', | ||
data: `Feature: Minimal | ||
Scenario: minimalistic | ||
Given the minimalism | ||
`, | ||
media: Media.fromObject({ | ||
encoding: 'UTF-8', | ||
contentType: 'text/x.cucumber.gherkin+plain', | ||
}), | ||
}) | ||
|
||
const wrappers = await streamToArray(gherkin.fromSources([source])) | ||
assert.strictEqual(wrappers.length, 3) | ||
}) | ||
}) | ||
|
||
async function streamToArray(readableStream: Readable): Promise<Wrapper[]> { | ||
return new Promise<Wrapper[]>((resolve: (wrappers:Wrapper[]) => void, reject: (err:Error) => void) => { | ||
const items: Wrapper[] = [] | ||
readableStream.on('data', items.push.bind(items)) | ||
readableStream.on('error', (err:Error) => reject(err)) | ||
readableStream.on('end', () => resolve(items)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
--recursive | ||
--require ts-node/register |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es6"], | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"rootDir": ".", | ||
"outDir": "dist" | ||
}, | ||
"files": [ | ||
"test/GherkinTypeScriptTest.ts" | ||
] | ||
} |