diff --git a/testbed/config.xml b/testbed/config.xml
index 2fe8268a..a1f4ea3f 100644
--- a/testbed/config.xml
+++ b/testbed/config.xml
@@ -7,10 +7,16 @@
Testbed application for Branch.IO Cordova.
+
+
+
+
+
+
@@ -26,7 +32,6 @@
-
-
+
diff --git a/testbed/init.sh b/testbed/init.sh
index 02bcfce8..0604b9bc 100644
--- a/testbed/init.sh
+++ b/testbed/init.sh
@@ -1,4 +1,9 @@
#!/bin/bash
cordova platform add ios android
+
cordova plugin add ../ --link --variable BRANCH_LIVE_KEY=key_live_fnmRM1FXtu11t6e4LU8WsldpvDcA0bzv --variable URI_SCHEME=testbed --variable ENCODED_ID=X9Ug
cordova plugin add https://github.com/nordnet/cordova-universal-links-plugin.git
+
+# Include this plugin if you want to run a unit-test for the plugin
+cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git
+cordova plugin add ../tests --link --variable BRANCH_LIVE_KEY=key_live_fnmRM1FXtu11t6e4LU8WsldpvDcA0bzv --variable URI_SCHEME=testbed --variable ENCODED_ID=X9Ug
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 00000000..c049af96
--- /dev/null
+++ b/tests/README.md
@@ -0,0 +1,10 @@
+# Running Plugin Tests
+
+1. Use your existing cordova app, or create a new one.
+2. Add this plugins:
+```
+cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git
+cordova plugin add https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git#:/tests
+```
+3. Change the start page in `config.xml` with `` or navigate to `cdvtests/index.html` from within your app.
+4. That's it.
\ No newline at end of file
diff --git a/tests/plugin.xml b/tests/plugin.xml
new file mode 100644
index 00000000..9d61826c
--- /dev/null
+++ b/tests/plugin.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ branch-cordova-sdk-tests
+ Apache 2.0
+
+
+
+
diff --git a/tests/tests.js b/tests/tests.js
new file mode 100644
index 00000000..6fa8b552
--- /dev/null
+++ b/tests/tests.js
@@ -0,0 +1,174 @@
+/**
+ * Branch.IO Cordova Plugin Unit-Test
+ * ----------------------------------
+ */
+/* jshint jasmine: true */
+
+exports.defineAutoTests = function () {
+
+ describe('Branch.IO SDK (Branch)', function () {
+ it('should exist', function () {
+ expect(window.Branch).toBeDefined();
+ });
+ it('should contain a method called getLatestReferringParams()', function () {
+ expect(window.Branch.getLatestReferringParams).toBeDefined();
+ expect(typeof(window.Branch.getLatestReferringParams)).toBe('function');
+ });
+ it('should contain a method called getFirstReferringParams()', function () {
+ expect(window.Branch.getFirstReferringParams).toBeDefined();
+ expect(typeof(window.Branch.getFirstReferringParams)).toBe('function');
+ });
+ it('should contain a method called setIdentity()', function () {
+ expect(window.Branch.setIdentity).toBeDefined();
+ expect(typeof(window.Branch.setIdentity)).toBe('function');
+ });
+ it('should contain a method called logout()', function () {
+ expect(window.Branch.logout).toBeDefined();
+ expect(typeof(window.Branch.logout)).toBe('function');
+ });
+ it('should contain a method called createBranchUniversalObject()', function () {
+ expect(window.Branch.createBranchUniversalObject).toBeDefined();
+ expect(typeof(window.Branch.createBranchUniversalObject)).toBe('function');
+ });
+ it('should contain a method called userCompletedAction()', function () {
+ expect(window.Branch.userCompletedAction).toBeDefined();
+ expect(typeof(window.Branch.userCompletedAction)).toBe('function');
+ });
+ it('should contain a method called loadRewards()', function () {
+ expect(window.Branch.loadRewards).toBeDefined();
+ expect(typeof(window.Branch.loadRewards)).toBe('function');
+ });
+ it('should contain a method called redeemRewards()', function () {
+ expect(window.Branch.redeemRewards).toBeDefined();
+ expect(typeof(window.Branch.redeemRewards)).toBe('function');
+ });
+ it('should contain a method called creditHistory()', function () {
+ expect(window.Branch.creditHistory).toBeDefined();
+ expect(typeof(window.Branch.creditHistory)).toBe('function');
+ });
+ });
+
+ describe('Branch.getLatestReferringParams()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return an object response', function (done) {
+ window.Branch.getLatestReferringParams().then(function (res) {
+ expect(typeof(res)).toBe('object');
+ done();
+ });
+ });
+ });
+
+ describe('Branch.getFirstReferringParams()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return an object response', function (done) {
+ window.Branch.getFirstReferringParams().then(function (res) {
+ expect(typeof(res)).toBe('object');
+ done();
+ });
+ });
+ });
+
+ describe('Branch.setIdentity()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return "Success" response', function (done) {
+ window.Branch.setIdentity('new_identity').then(function (res) {
+ expect(res).toBe('Success');
+ done();
+ });
+ });
+ });
+
+ describe('Branch.createBranchUniversalObject()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return an object instance', function (done) {
+ var properties = {
+ canonicalIdentifier: 'testbed',
+ title: 'testbed',
+ contentDescription: 'Testbed Application',
+ contentImageUrl: 'https://imgflip.com/s/meme/Derp.jpg',
+ contentIndexingMode: 'public',
+ contentMetadata: {}
+ };
+ window.Branch.createBranchUniversalObject(properties).then(function (res) {
+ expect(typeof(res)).toBe('object');
+ expect(res.message).toBe('success');
+ done();
+ });
+ });
+ });
+
+ describe('Branch.userCompletedAction()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should successfully execute the method', function (done) {
+ window.Branch.userCompletedAction('login');
+ expect('Success').toBe('Success');
+ done();
+ });
+ });
+
+ describe('Branch.loadRewards()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return an object response', function (done) {
+ window.Branch.loadRewards().then(function (res) {
+ expect(typeof(res)).toBe('object');
+ done();
+ });
+ });
+ });
+
+ describe('Branch.redeemRewards()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return an object/string error response', function (done) {
+ window.Branch.redeemRewards(100).then(function (res) {
+ expect(typeof(res)).toBe('object');
+ done();
+ }, function (err) {
+ expect(typeof(err)).toBe('string');
+ done();
+ });
+ });
+ });
+
+ describe('Branch.creditHistory()', function () {
+ beforeEach(function () {
+ window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
+ window.Branch.setDebug(true);
+ window.Branch.initSession();
+ });
+ it('should return the credit balance', function (done) {
+ window.Branch.creditHistory().then(function (res) {
+ expect(typeof(res)).toBe('number');
+ done();
+ });
+ });
+ });
+
+};