Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix snippet syntax #711

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/custom_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Feature: custom formatter
Message:
Undefined. Implement with the following snippet:

this.Given('an undefined step', function (callback) {
Given('an undefined step', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Expand Down
6 changes: 3 additions & 3 deletions features/snippets_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ Feature: snippets formatter
Then it fails
And it outputs the text:
"""
this.Given('undefined step A', function (callback) {
Given('undefined step A', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});

this.When('undefined step B', function (callback) {
When('undefined step B', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});

this.Then('undefined step C', function (callback) {
Then('undefined step C', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Expand Down
6 changes: 3 additions & 3 deletions features/step_definition_snippets_i18n.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ Feature: step definition snippets i18n
Then it fails
And the output contains the text:
"""
this.Given('undefined step A', function (callback) {
Given('undefined step A', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
"""
And the output contains the text:
"""
this.When('undefined step B', function (callback) {
When('undefined step B', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
"""
And the output contains the text:
"""
this.Then('undefined step C', function (callback) {
Then('undefined step C', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Expand Down
2 changes: 1 addition & 1 deletion features/step_definition_snippets_interfaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: step definition snippets custom syntax
Then it fails
And the output contains the text:
"""
this.Given('an undefined step', <SNIPPET_FUNCTION_KEYWORD_AND_PARAMETERS> {
Given('an undefined step', <SNIPPET_FUNCTION_KEYWORD_AND_PARAMETERS> {
// Write code here that turns the phrase above into concrete actions
<SNIPPET_IMPLEMENTATION>;
});
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/cli_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defineSupportCode(function({When, Then}) {
}
}
parameters.push('callback')
const expectedOutput = 'this.' + step + '(' + regExp + ', function (' + parameters.join(', ') + ') {\n'
const expectedOutput = step + '(' + regExp + ', function (' + parameters.join(', ') + ') {\n'
const actualOutput = normalizeText(this.lastRun.output)
expect(actualOutput).to.include(expectedOutput)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class JavaScriptSnippetSyntax {
}

const snippet =
'this.' + functionName + '(\'' + pattern.replace(/'/g, '\\\'') + '\', ' + functionKeyword + '(' + parameters.join(', ') + ') {' + '\n' +
functionName + '(\'' + pattern.replace(/'/g, '\\\'') + '\', ' + functionKeyword + '(' + parameters.join(', ') + ') {' + '\n' +
' // ' + comment + '\n' +
' ' + implementation + '\n' +
'});'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function (arg1, arg2, callback) {' + '\n' +
'functionName(\'pattern\', function (arg1, arg2, callback) {' + '\n' +
' // comment' + '\n' +
' callback(null, \'pending\');' + '\n' +
'});'
Expand All @@ -26,7 +26,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function *(arg1, arg2) {' + '\n' +
'functionName(\'pattern\', function *(arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand All @@ -42,7 +42,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
'functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand All @@ -58,7 +58,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
'functionName(\'pattern\', function (arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand All @@ -74,7 +74,7 @@ describe('JavascriptSnippetSyntax', function () {
it('returns the proper snippet', function () {
const actual = this.syntax.build('functionName', 'pattern\'', ['arg1', 'arg2', 'callback'], 'comment')
const expected =
'this.functionName(\'pattern\\\'\', function (arg1, arg2) {' + '\n' +
'functionName(\'pattern\\\'\', function (arg1, arg2) {' + '\n' +
' // comment' + '\n' +
' return \'pending\';' + '\n' +
'});'
Expand Down