-
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
7 changed files
with
136 additions
and
3 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,72 @@ | ||
import { base64Encode } from '../../src/actions'; | ||
|
||
describe('base64Encode function', () => { | ||
|
||
it('is a function', () => { | ||
expect(typeof base64Encode).toBe('function'); | ||
}); | ||
|
||
it('builds a base64Encode action (encode with no line break)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode', | ||
WFWorkflowActionParameters: { | ||
WFEncodeMode: 'Encode', | ||
WFBase64LineBreakMode: 'None', | ||
}, | ||
}; | ||
const actual = base64Encode({ | ||
encodeMode: 'Encode', | ||
lineBreakMode: 'None', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a base64Encode action (encode with 64-char line break)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode', | ||
WFWorkflowActionParameters: { | ||
WFEncodeMode: 'Encode', | ||
WFBase64LineBreakMode: 'Every 64 Characters', | ||
}, | ||
}; | ||
const actual = base64Encode({ | ||
encodeMode: 'Encode', | ||
lineBreakMode: 'Every 64 Characters', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a base64Encode action (encode with 76-char line break)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode', | ||
WFWorkflowActionParameters: { | ||
WFEncodeMode: 'Encode', | ||
WFBase64LineBreakMode: 'Every 76 Characters', | ||
}, | ||
}; | ||
const actual = base64Encode({ | ||
encodeMode: 'Encode', | ||
lineBreakMode: 'Every 76 Characters', | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a base64Encode action (decode)', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode', | ||
WFWorkflowActionParameters: { | ||
WFEncodeMode: 'Decode', | ||
WFBase64LineBreakMode: 'Every 76 Characters', | ||
}, | ||
}; | ||
const actual = base64Encode({ | ||
encodeMode: 'Decode', | ||
}); | ||
|
||
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,41 @@ | ||
import { withActionOutput } from '../utils'; | ||
|
||
import WFBase64LineBreakMode from '../interfaces/WF/WFBase64LineBreakMode'; | ||
import WFEncodeMode from '../interfaces/WF/WFEncodeMode'; | ||
import WFSerialization from '../interfaces/WF/WFSerialization'; | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* Base 64 Encode Action. Base 64-encode content. | ||
* | ||
* ```js | ||
* base64Encode({ | ||
* 'address': 'External', | ||
* 'type': 'IPv4', | ||
* }); | ||
* ``` | ||
*/ | ||
const base64Encode = ( | ||
options: { | ||
/** The encoding mode to use */ | ||
encodeMode?: WFEncodeMode, | ||
|
||
/** The line break mode to use */ | ||
lineBreakMode?: WFSerialization | WFBase64LineBreakMode, | ||
}, | ||
): WFWorkflowAction => { | ||
const { | ||
encodeMode = 'Encode', | ||
lineBreakMode = 'Every 76 Characters', | ||
} = options; | ||
|
||
return { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode', | ||
WFWorkflowActionParameters: { | ||
WFEncodeMode: encodeMode, | ||
WFBase64LineBreakMode: lineBreakMode, | ||
}, | ||
}; | ||
}; | ||
|
||
export default withActionOutput(base64Encode); |
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,7 @@ | ||
type WFBase64LineBreakMode = ( | ||
'None' | ||
| 'Every 64 Characters' | ||
| 'Every 76 Characters' | ||
); | ||
|
||
export default WFBase64LineBreakMode; |
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,6 @@ | ||
type WFEncodeMode = ( | ||
'Encode' | ||
| 'Decode' | ||
); | ||
|
||
export default WFEncodeMode; |
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