Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getStepKeywordType({ keyword, language, previousKeywordType }) {
const dialect = Gherkin.dialects()[language]
const type = _.find(['given', 'when', 'then', 'and', 'but'], key =>
_.includes(dialect[key], keyword)
)
switch (type) {
case 'when':
return types.EVENT
case 'then':
return types.OUTCOME
case 'and':
case 'but':
if (previousKeywordType) {
return previousKeywordType
}
// fallthrough
default:
return types.PRECONDITION
export function getLanguages() {
const rows = _.map(Gherkin.dialects(), (data, isoCode) => [
isoCode,
data.name,
data.native,
])
return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows)
}
export function getKeywords(isoCode) {
const language = Gherkin.dialects()[isoCode]
const rows = _.map(keywords, keyword => {
const words = _.map(language[keyword], s => `"${s}"`).join(', ')
return [titleCase(keyword), words]
})
return getAsTable(['ENGLISH KEYWORD', 'NATIVE KEYWORDS'], rows)
}
static validateLanguage(val) {
if (!_.includes(_.keys(Gherkin.dialects()), val)) {
throw new Error(`Unsupported ISO 639-1: ${val}`)
}
return val
}