-
Notifications
You must be signed in to change notification settings - Fork 295
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 #1385 from input-output-hk/feature/ddw-637-add-tim…
…estamp-for-paper-wallet-pdf-name [DDW-637] Add timestamp for Paper wallet
- Loading branch information
Showing
26 changed files
with
349 additions
and
95 deletions.
There are no files selected for viewing
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,21 @@ | ||
@unit | ||
Feature: Generate fileName with timestamp | ||
|
||
Scenario: I don't pass any props and use the default ones | ||
Given I dont pass any props to the function | ||
Then the prefix should be "logs" | ||
And the extention should be "zip" | ||
And the time should be converted into UTC | ||
|
||
Scenario Outline: I pass the following props | ||
Given I pass the following props to the function: | ||
| prefix | extention | isUTC | | ||
| <prefix> | <extention> | <isUTC> | | ||
Then the prefix should be "<prefix>" | ||
And the extention should be "<extention>" | ||
And the time <isUTC> be converted into UTC | ||
|
||
Examples: | ||
| prefix | extention | isUTC | | ||
| testPrefix | docx | should | | ||
| | pdf | shouldn't | |
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
57 changes: 57 additions & 0 deletions
57
features/tests/unit/steps/generate-filename-with-timestamp-steps.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,57 @@ | ||
import { Given, When, Then } from 'cucumber'; | ||
import { expect } from 'chai'; | ||
import { pickBy, identity } from 'lodash'; | ||
import { | ||
generateFileNameWithTimestamp, | ||
defaultProps, | ||
} from '../../../../source/common/utils/files'; | ||
|
||
const getDataFromFunction = props => { | ||
const filename = generateFileNameWithTimestamp(props); | ||
const prefix = filename.match(/^[^-]*[^ -]/i)[0]; | ||
const extention = filename.match(/\.[0-9a-z]+$/i)[0].replace('.', ''); | ||
const isUTC = !!filename.match(`Z.${extention}`); | ||
return { | ||
filename, | ||
prefix, | ||
extention, | ||
isUTC, | ||
}; | ||
}; | ||
|
||
Given('I dont pass any props to the function', function() { | ||
const { filename, extention, prefix, isUTC } = getDataFromFunction(); | ||
this.context.filename = filename; | ||
this.context.extention = extention; | ||
this.context.prefix = prefix; | ||
this.context.isUTC = isUTC; | ||
}); | ||
|
||
Given('I pass the following props to the function:', function(data) { | ||
let [expectedProps] = data.hashes(); | ||
expectedProps = pickBy(expectedProps, identity); | ||
if (expectedProps.isUTC) | ||
expectedProps.isUTC = Boolean(expectedProps.isUTC === 'should'); | ||
const { filename, extention, prefix, isUTC } = getDataFromFunction( | ||
expectedProps | ||
); | ||
this.context.filename = filename; | ||
this.context.extention = extention; | ||
this.context.prefix = prefix; | ||
this.context.isUTC = isUTC; | ||
}); | ||
|
||
Then('the prefix should be {string}', function(prefix) { | ||
const expectedPrefix = prefix || defaultProps.prefix; | ||
expect(this.context.prefix).to.equal(expectedPrefix); | ||
}); | ||
|
||
Then('the extention should be {string}', function(extention) { | ||
const expectedExtention = extention || defaultProps.extention; | ||
expect(this.context.extention).to.equal(expectedExtention); | ||
}); | ||
|
||
Then(/^the time (should|shouldn't) be converted into UTC/, function(state) { | ||
const isUTC = state === 'should'; | ||
expect(isUTC).to.equal(this.context.isUTC); | ||
}); |
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
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
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
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
Oops, something went wrong.