-
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
82 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,33 @@ | ||
import { getDeviceDetails } from '../../src/actions'; | ||
|
||
describe('getDeviceDetails function', () => { | ||
|
||
it('is a function', () => { | ||
expect(typeof getDeviceDetails).toBe('function'); | ||
}); | ||
|
||
it('builds a getDeviceDetails action', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.getdevicedetails', | ||
WFWorkflowActionParameters: { | ||
WFDeviceDetail: 'Device Name', | ||
}, | ||
}; | ||
const actual = getDeviceDetails({}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a getDeviceDetails action when a detail is passed', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.getdevicedetails', | ||
WFWorkflowActionParameters: { | ||
WFDeviceDetail: 'System Version', | ||
}, | ||
}; | ||
const actual = getDeviceDetails({ detail: 'System Version' }); | ||
|
||
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,33 @@ | ||
import { withActionOutput } from '../utils'; | ||
|
||
import WFDeviceDetail from '../interfaces/WF/WFDeviceDetail'; | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* Get Device Details Action. Returns a particular property of the device. | ||
* | ||
* ```js | ||
* getDeviceDetails({ | ||
* 'detail': 'Device Name', | ||
* }); | ||
* ``` | ||
*/ | ||
const getDeviceDetails = ( | ||
options: { | ||
/** The particular detail to retrieve */ | ||
detail?: WFDeviceDetail, | ||
}, | ||
): WFWorkflowAction => { | ||
const { | ||
detail = 'Device Name', | ||
} = options; | ||
|
||
return { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.getdevicedetails', | ||
WFWorkflowActionParameters: { | ||
WFDeviceDetail: detail, | ||
}, | ||
}; | ||
}; | ||
|
||
export default withActionOutput(getDeviceDetails); |
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 @@ | ||
type WFDeviceDetail = ( | ||
'Device Name' | ||
| 'Device Model' | ||
| 'System Version' | ||
| 'Screen Width' | ||
| 'Screen Height' | ||
| 'Current Volume' | ||
| 'Current Brightness' | ||
); | ||
|
||
export default WFDeviceDetail; |
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