-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { generateHash } from '../../src/actions'; | ||
|
||
describe('generateHash function', () => { | ||
|
||
it('is a function', () => { | ||
expect(typeof generateHash).toBe('function'); | ||
}); | ||
|
||
it('builds a generateHash action', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.hash', | ||
WFWorkflowActionParameters: { | ||
WFHashType: 'MD5', | ||
}, | ||
}; | ||
const actual = generateHash({}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a generateHash action (MD5)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.hash', | ||
WFWorkflowActionParameters: { | ||
WFHashType: 'MD5', | ||
}, | ||
}; | ||
const actual = generateHash({ | ||
type: 'MD5', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a generateHash action (SHA1)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.hash', | ||
WFWorkflowActionParameters: { | ||
WFHashType: 'SHA1', | ||
}, | ||
}; | ||
const actual = generateHash({ | ||
type: 'SHA1', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a generateHash action (SHA256)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.hash', | ||
WFWorkflowActionParameters: { | ||
WFHashType: 'SHA256', | ||
}, | ||
}; | ||
const actual = generateHash({ | ||
type: 'SHA256', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a generateHash action (SHA512)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.hash', | ||
WFWorkflowActionParameters: { | ||
WFHashType: 'SHA512', | ||
}, | ||
}; | ||
const actual = generateHash({ | ||
type: 'SHA512', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
}); |
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,34 @@ | ||
import { withActionOutput } from '../utils'; | ||
|
||
import WFHashType from '../interfaces/WF/WFHashType'; | ||
import WFSerialization from '../interfaces/WF/WFSerialization'; | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* Generate Hash Action. Generates a MD5/SHA1 hash from the input. | ||
* | ||
* ```js | ||
* generateHash({ | ||
* type: 'MD5' | ||
* }); | ||
* ``` | ||
*/ | ||
const generateHash = ( | ||
options: { | ||
/** The type of hash to use */ | ||
type?: WFSerialization | WFHashType, | ||
}, | ||
): WFWorkflowAction => { | ||
const { | ||
type = 'MD5', | ||
} = options; | ||
|
||
return { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.hash', | ||
WFWorkflowActionParameters: { | ||
WFHashType: type, | ||
}, | ||
}; | ||
}; | ||
|
||
export default withActionOutput(generateHash); |
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,8 @@ | ||
type WFHashType = ( | ||
'MD5' | ||
| 'SHA1' | ||
| 'SHA256' | ||
| 'SHA512' | ||
); | ||
|
||
export default WFHashType; |
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