-
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
10 changed files
with
164 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,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,34 @@ | ||
import { withActionOutput } from '../utils'; | ||
|
||
import WFDeviceDetail from '../interfaces/WF/WFDeviceDetail'; | ||
import WFSerialization from '../interfaces/WF/WFSerialization'; | ||
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?: WFSerialization | 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { withActionOutput } from '../utils'; | ||
|
||
import WFCellularDetail from '../interfaces/WF/WFCellularDetail'; | ||
import WFNetworkDetailsNetwork from '../interfaces/WF/WFNetworkDetailsNetwork'; | ||
import WFSerialization from '../interfaces/WF/WFSerialization'; | ||
import WFWiFiDetail from '../interfaces/WF/WFWiFiDetail'; | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* Get Network Details Action. Gets various network-related information from | ||
* the device. | ||
* | ||
* ```js | ||
* getNetworkDetails({ | ||
* network: 'Wi-Fi', | ||
* get: 'Network Name', | ||
* }); | ||
* | ||
* getNetworkDetails({ | ||
* network: 'Cellular', | ||
* get: 'Carrier Name', | ||
* }); | ||
* ``` | ||
*/ | ||
const getNetworkDetails = ( | ||
options: { | ||
/** The type of network to look at */ | ||
network?: WFNetworkDetailsNetwork, | ||
|
||
/** The particular network detail to retrieve */ | ||
attribute?: WFSerialization | WFWiFiDetail | WFCellularDetail, | ||
}, | ||
): WFWorkflowAction => { | ||
const { | ||
network = 'Wi-Fi', | ||
attribute = 'Network Name', | ||
} = options; | ||
|
||
let detailKey = 'WFWiFiDetail'; | ||
if (network === 'Cellular') { | ||
detailKey = 'WFCellularDetail'; | ||
} | ||
|
||
return { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.getwifi', | ||
WFWorkflowActionParameters: { | ||
WFNetworkDetailsNetwork: network, | ||
[detailKey]: attribute, | ||
}, | ||
}; | ||
}; | ||
|
||
export default withActionOutput(getNetworkDetails); |
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 WFCellularDetail = ( | ||
'Carrier Name' | ||
| 'Radio Technology' | ||
| 'Country Code' | ||
| 'WFTextTokenAttachment' | ||
); | ||
|
||
export default WFCellularDetail; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type WFNetworkDetailsNetwork = ( | ||
'Wi-Fi' | ||
| 'Cellular' | ||
); | ||
|
||
export default WFNetworkDetailsNetwork; |
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 WFWiFiDetail = ( | ||
'Network Name' | ||
| 'BSSID' | ||
); | ||
|
||
export default WFWiFiDetail; |
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