This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from JB1905/master
Add setWiFi & setCellularData actions
- Loading branch information
Showing
6 changed files
with
134 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,34 @@ | ||
import { setCellularData } from '../../src/actions'; | ||
|
||
describe('setCellularData function', () => { | ||
|
||
it('is a function', () => { | ||
expect(typeof setCellularData).toBe('function'); | ||
}); | ||
|
||
it('builds a setCellularData action when no value is passed', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.cellulardata.set', | ||
WFWorkflowActionParameters: { | ||
OnValue: true, | ||
}, | ||
}; | ||
const actual = setCellularData({}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a setCellularData action with given value', () => { | ||
const value = false; | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.cellulardata.set', | ||
WFWorkflowActionParameters: { | ||
OnValue: value, | ||
}, | ||
}; | ||
const actual = setCellularData({ value }); | ||
|
||
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 { setWiFi } from '../../src/actions'; | ||
|
||
describe('setWiFi function', () => { | ||
|
||
it('is a function', () => { | ||
expect(typeof setWiFi).toBe('function'); | ||
}); | ||
|
||
it('builds a setWiFi action when no value is passed', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.wifi.set', | ||
WFWorkflowActionParameters: { | ||
OnValue: true, | ||
}, | ||
}; | ||
const actual = setWiFi({}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a setWiFi action with given value', () => { | ||
const value = false; | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.wifi.set', | ||
WFWorkflowActionParameters: { | ||
OnValue: value, | ||
}, | ||
}; | ||
const actual = setWiFi({ value }); | ||
|
||
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
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,30 @@ | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* Set setCellularData Action. Sets the device's cellular data to on or off. | ||
* | ||
* ```js | ||
* setCellularData({ | ||
* value: true, | ||
* }); | ||
* ``` | ||
*/ | ||
const setCellularData = ( | ||
options: { | ||
/** Enable or disable cellular data */ | ||
value?: boolean, | ||
}, | ||
): WFWorkflowAction => { | ||
const { | ||
value = true, | ||
} = options; | ||
|
||
return { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.cellulardata.set', | ||
WFWorkflowActionParameters: { | ||
OnValue: value, | ||
}, | ||
}; | ||
}; | ||
|
||
export default setCellularData; |
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,30 @@ | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* Set setWiFi Action. Sets the device's WiFi to on or off. | ||
* | ||
* ```js | ||
* setWiFi({ | ||
* value: true, | ||
* }); | ||
* ``` | ||
*/ | ||
const setWiFi = ( | ||
options: { | ||
/** Enable or disable WiFi */ | ||
value?: boolean, | ||
}, | ||
): WFWorkflowAction => { | ||
const { | ||
value = true, | ||
} = options; | ||
|
||
return { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.wifi.set', | ||
WFWorkflowActionParameters: { | ||
OnValue: value, | ||
}, | ||
}; | ||
}; | ||
|
||
export default setWiFi; |
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