Tests user tracking enable/disable api
MODIFY
test/helpers/RNBranch.mock.js
test/helpers/RNBranch.mock.js
import React from 'react-native'
const defaultSession = {params: {}, error: null}
+let tackingDisabled = false
React.NativeModules.RNBranch = {
// Mock constants exported by native layers
@@ -35,7 +36,18 @@ React.NativeModules.RNBranch = {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(defaultSession), 500)
})
- }
+ },
+
+ disableTracking(disable) {
+ // Just mock user tracking enable/disable
+ tackingDisabled = disable
+ },
+
+ isTrackingDisabled() {
+ return new Promise((resolve, reject) => {
+ resolve(tackingDisabled)
+ })
+ },
}
// This only has to exist to be passed to the NativeEventEmitter

MODIFY
test/index.js
test/index.js
@@ -21,6 +21,26 @@ test.afterEach(() => {
unmock()
})
+test('can disable user tracking', t => {
+ return new Promise((resolve, reject) => {
+ branch.disableTracking(true)
+ branch.isTrackingDisabled().then((disabled) => {
+ if(disabled) resolve()
+ else reject('Could not disable user tracking')
+ })
+ })
+})
+
+test('can enable user tracking', t => {
+ return new Promise((resolve, reject) => {
+ branch.disableTracking(false)
+ branch.isTrackingDisabled().then((disabled) => {
+ if(!disabled) resolve()
+ else reject('Could not enable user tracking')
+ })
+ })
+})
+
test('subscribe returns init session', t => {
return new Promise((resolve, reject) => {
branch.subscribe((session) => {

Tests user tracking enable/disable api