Skip to content

Commit

Permalink
revert json formatter mime type (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Jan 4, 2018
1 parent 7bf5936 commit ab0eb00
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
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

0 comments on commit ab0eb00

Please sign in to comment.