-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from percy/json-output
Add output_format arg, that provides for JSON output of build status
- Loading branch information
Showing
7 changed files
with
87 additions
and
14 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/percy-storybook/src/__tests__/getMinimumHeight-tests.js
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
18 changes: 18 additions & 0 deletions
18
packages/percy-storybook/src/__tests__/getOutputFormat-tests.js
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,18 @@ | ||
import getOutputFormat from '../getOutputFormat'; | ||
|
||
it('returns text when passed text', () => { | ||
expect(getOutputFormat('TEXT')).toEqual('text'); | ||
expect(getOutputFormat('text')).toEqual('text'); | ||
}); | ||
|
||
it('returns json when passed JSON', () => { | ||
expect(getOutputFormat('JSON')).toEqual('json'); | ||
expect(getOutputFormat('json')).toEqual('json'); | ||
}); | ||
|
||
it('raises an error if called with an invalid value', () => { | ||
expect(() => getOutputFormat()).toThrow(); | ||
expect(() => getOutputFormat('xml')).toThrow(); | ||
expect(() => getOutputFormat(7)).toThrow(); | ||
expect(() => getOutputFormat('')).toThrow(); | ||
}); |
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,11 @@ | ||
export default function getOutputFormat(outputFormatString) { | ||
const normalizedOutputFormat = outputFormatString.toLowerCase(); | ||
|
||
if (normalizedOutputFormat != 'text' && normalizedOutputFormat != 'json') { | ||
throw new Error( | ||
`Output format must be either 'text' or 'json'. Received: ${outputFormatString}`, | ||
); | ||
} | ||
|
||
return normalizedOutputFormat; | ||
} |
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