Skip to content

Commit

Permalink
Merge 00afa2e into 0cbab36
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya committed Nov 30, 2018
2 parents 0cbab36 + 00afa2e commit 66a73f2
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 0 deletions.
33 changes: 33 additions & 0 deletions __tests__/actions/getDeviceDetails.spec.ts
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);
});

});
33 changes: 33 additions & 0 deletions src/actions/getDeviceDetails.ts
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);
2 changes: 2 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import count from './count';
import exitShortcut from './exitShortcut';
import getBatteryLevel from './getBatteryLevel';
import getContentsOfUrl from './getContentsOfUrl';
import getDeviceDetails from './getDeviceDetails';
import getDictionaryValue from './getDictionaryValue';
import getName from './getName';
import getType from './getType';
Expand Down Expand Up @@ -46,6 +47,7 @@ export {
exitShortcut,
getBatteryLevel,
getContentsOfUrl,
getDeviceDetails,
getDictionaryValue,
getName,
getType,
Expand Down
11 changes: 11 additions & 0 deletions src/interfaces/WF/WFDeviceDetail.ts
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;
1 change: 1 addition & 0 deletions src/interfaces/WF/WFWorkflowActionIdentifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type WFWorkflowActionIdentifier = (
| 'is.workflow.actions.exit'
| 'is.workflow.actions.flashlight'
| 'is.workflow.actions.getbatterylevel'
| 'is.workflow.actions.getdevicedetails'
| 'is.workflow.actions.getitemname'
| 'is.workflow.actions.getitemtype'
| 'is.workflow.actions.gettext'
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/WF/WFWorkflowActionParameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import WFAskActionDateGranularity from './WFAskActionDateGranularity';
import WFCondition from './WFCondition';
import WFCountType from './WFCountType';
import WFDeviceDetail from './WFDeviceDetail';
import WFFlashlightSetting from './WFFlashlightSetting';
import WFGetDictionaryValueType from './WFGetDictionaryValueType';
import WFHTTPBodyType from './WFHTTPBodyType';
Expand All @@ -27,6 +28,7 @@ interface WFWorkflowActionParameters {
WFControlFlowMode?: number;
WFCountType?: WFCountType;
WFDelayTime?: number;
WFDeviceDetail?: WFDeviceDetail;
WFDictionaryKey?: string;
WFDontIncludeFileExtension?: boolean;
WFFlashlightSetting?: WFFlashlightSetting;
Expand Down

0 comments on commit 66a73f2

Please sign in to comment.