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

revert json formatter #995

Merged
merged 5 commits into from
Jan 4, 2018
Merged
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
18 changes: 9 additions & 9 deletions features/attachments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Feature: Attachments
"""
When I run cucumber.js
Then the "Before" hook has the attachment
| DATA | MEDIA ENCODING | MEDIA TYPE |
| iVBORw== | base64 | image/png |
| DATA | MIME TYPE |
| iVBORw== | image/png |

Scenario: Attach a stream (callback)
Given a file named "features/support/hooks.js" with:
Expand All @@ -50,8 +50,8 @@ Feature: Attachments
"""
When I run cucumber.js
Then the "Before" hook has the attachment
| DATA | MEDIA ENCODING | MEDIA TYPE |
| iVBORw== | base64 | image/png |
| DATA | MIME TYPE |
| iVBORw== | image/png |

Scenario: Attach a stream (promise)
Given a file named "features/support/hooks.js" with:
Expand All @@ -72,8 +72,8 @@ Feature: Attachments
"""
When I run cucumber.js
Then the "Before" hook has the attachment
| DATA | MEDIA ENCODING | MEDIA TYPE |
| iVBORw== | base64 | image/png |
| DATA | MIME TYPE |
| iVBORw== | image/png |

Scenario: Attach from a before hook
Given a file named "features/support/hooks.js" with:
Expand All @@ -88,7 +88,7 @@ Feature: Attachments
"""
When I run cucumber.js
Then the "Before" hook has the attachment
| DATA | MEDIA TYPE |
| DATA | MIME TYPE |
| text | text/plain |

Scenario: Attach from an after hook
Expand All @@ -104,7 +104,7 @@ Feature: Attachments
"""
When I run cucumber.js
Then the "After" hook has the attachment
| DATA | MEDIA TYPE |
| DATA | MIME TYPE |
| text | text/plain |

Scenario: Attach from a step definition
Expand All @@ -120,5 +120,5 @@ Feature: Attachments
"""
When I run cucumber.js
Then the step "a step" has the attachment
| DATA | MEDIA TYPE |
| DATA | MIME TYPE |
| text | text/plain |
10 changes: 2 additions & 8 deletions features/step_definitions/json_output_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ defineSupportCode(({ Then }) => {
const tableRowData = table.hashes()[0]
const expectedAttachment = {
data: tableRowData.DATA,
media: { type: tableRowData['MEDIA TYPE'] }
}
if (tableRowData['MEDIA ENCODING']) {
expectedAttachment.media.encoding = tableRowData['MEDIA ENCODING']
mime_type: tableRowData['MIME TYPE']
}
expect(step.embeddings[0]).to.eql(expectedAttachment)
})
Expand All @@ -105,10 +102,7 @@ defineSupportCode(({ Then }) => {
const tableRowData = table.hashes()[0]
const expectedAttachment = {
data: tableRowData.DATA,
media: { type: tableRowData['MEDIA TYPE'] }
}
if (tableRowData['MEDIA ENCODING']) {
expectedAttachment.media.encoding = tableRowData['MEDIA ENCODING']
mime_type: tableRowData['MIME TYPE']
}
expect(hook.embeddings[0]).to.eql(expectedAttachment)
})
Expand Down
7 changes: 6 additions & 1 deletion src/formatter/json_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ export default class JsonFormatter extends Formatter {
}
}
if (_.size(testStep.attachments) > 0) {
data.embeddings = testStep.attachments
data.embeddings = testStep.attachments.map(attachment => {
return {
data: attachment.data,
mime_type: attachment.media.type
}
})
}
return data
}
Expand Down
4 changes: 2 additions & 2 deletions src/formatter/json_formatter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ describe('JsonFormatter', function() {
it('outputs the step with embeddings', function() {
const features = JSON.parse(this.output)
expect(features[0].elements[0].steps[0].embeddings).to.eql([
{ data: 'first data', media: { type: 'first media type' } },
{ data: 'second data', media: { type: 'second media type' } }
{ data: 'first data', mime_type: 'first media type' },
{ data: 'second data', mime_type: 'second media type' }
])
})
})
Expand Down