{"action":"created","comment":{"url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/comments/24440710","id":24440710,"diff_hunk":"@@ -0,0 +1,379 @@\n+/*\n+ * This file defines the unit tests for the main function\n+ */\n+\n+/**\n+ * Defines global test variables\n+ */\n+var maxWaitTime;\n+var asyncPollingInterval;\n+var params;\n+var branch;\n+var stubs = new goog.testing.PropertyReplacer();\n+var asyncTestCase = new goog.testing.ContinuationTestCase(\"Branch test case\");\n+\n+/**\n+ * Setup the Branch Function\n+ */\n+var setUpPage = function() {\n+\n+\tasyncTestCase.autoDiscoverTests();\n+\tG_testRunner.initialize(asyncTestCase);\n+\n+\t// Main Branch object\n+\tbranch = new Branch();\n+\tbranch.init('5680621892404085', function(err, data) {});\n+\n+\t// Maximum wait time for async tests (ms)\n+\tmaxWaitTime = 10000;\n+\n+\t// How often we should check for the finished state of an async test\n+\tasyncPollingInterval = 500;\n+\n+\t//Standard set of dummy params\n+\tparams = {\n+\t\tphone: \"5177401526\",\n+\t\ttags: ['tag1', 'tag2'],\n+\t\tchannel: 'sample app',\n+\t\tfeature: 'create link',\n+\t\tstage: 'created link',\n+\t\ttype: 1,\n+\t\tdata: {  \n+\t\t\tmydata: {\n+\t\t\t\tfoo: 'bar'\n+\t\t\t},\n+\t\t\t'$desktop_url': 'http://s3-us-west-1.amazonaws.com/branch-sdk/example.html',\n+\t\t\t'$og_title': 'Branch Metrics',\n+\t\t\t'$og_description': 'Branch Metrics',\n+\t\t\t'$og_image_url': 'http://branch.io/img/logo_icon_white.png'\n+\t\t}\n+\t};\n+}\n+\n+/**\n+ * Clean up post tests\n+ */\n+var tearDown = function() {\n+  stubs.reset();\n+};\n+\n+// ===========================================================================================\n+/**\n+ * SMS Tests\n+ */\n+\n+ // SMS sends with phone param\n+var testSMSLink = function() {\n+\n+\tvar recievedData = {};\n+\tvar expectedData = {};\n+\tvar recievedFired;\n+\t\n+\twaitForCondition(\n+\t\tfunction() {\n+\t\t\treturn recievedFired;\n+\t\t\t },\n+\t\tfunction() {\n+\t\t\tassertObjectEquals(\"should send SMS with phone number\", recievedData, expectedData);\n+\t\t},\n+\t\tasyncPollingInterval,\n+\t\tmaxWaitTime\n+\t);\n+\t\n+\tbranch.SMSLink(params, function(data) {\n+\t\trecievedFired = true;\n+\t\trecievedData = data;\n+\t});\n+};","path":"src/2_branch_tests.js","position":87,"original_position":87,"commit_id":"075f4b8bd3f127f327a6ad2e66048f05b927cf3c","original_commit_id":"075f4b8bd3f127f327a6ad2e66048f05b927cf3c","user":{"login":"dmitrig01","id":10422,"avatar_url":"https://avatars.githubusercontent.com/u/10422?v=3","gravatar_id":"","url":"https://api.github.com/users/dmitrig01","html_url":"https://github.com/dmitrig01","followers_url":"https://api.github.com/users/dmitrig01/followers","following_url":"https://api.github.com/users/dmitrig01/following{/other_user}","gists_url":"https://api.github.com/users/dmitrig01/gists{/gist_id}","starred_url":"https://api.github.com/users/dmitrig01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmitrig01/subscriptions","organizations_url":"https://api.github.com/users/dmitrig01/orgs","repos_url":"https://api.github.com/users/dmitrig01/repos","events_url":"https://api.github.com/users/dmitrig01/events{/privacy}","received_events_url":"https://api.github.com/users/dmitrig01/received_events","type":"User","site_admin":false},"body":"It looks like you're repeating the same structure in all of these tests - perhaps we can abstract this out into a helper function, so you can call it something like this:\r\n```\r\nvar testSMSLink = function() {\r\n    runTest(function(cb) {\r\n        branch.SMSLink(params, function(data) { cb(data); }\r\n    }, function(data) {\r\n        assertObjectEquals(\"should send SMS with phone number\", data, {});\r\n    });\r\n};\r\n```\r\n(i.e. first param is \"do the thing\" function, and second is assertions function)","created_at":"2015-02-10T19:12:01Z","updated_at":"2015-02-10T19:12:01Z","html_url":"https://github.com/BranchMetrics/Web-SDK/pull/8#discussion_r24440710","pull_request_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/comments/24440710"},"html":{"href":"https://github.com/BranchMetrics/Web-SDK/pull/8#discussion_r24440710"},"pull_request":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8","id":28846359,"html_url":"https://github.com/BranchMetrics/Web-SDK/pull/8","diff_url":"https://github.com/BranchMetrics/Web-SDK/pull/8.diff","patch_url":"https://github.com/BranchMetrics/Web-SDK/pull/8.patch","issue_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/8","number":8,"state":"open","locked":false,"title":"Implements sms on v2","user":{"login":"scotthasbrouck","id":4266945,"avatar_url":"https://avatars.githubusercontent.com/u/4266945?v=3","gravatar_id":"","url":"https://api.github.com/users/scotthasbrouck","html_url":"https://github.com/scotthasbrouck","followers_url":"https://api.github.com/users/scotthasbrouck/followers","following_url":"https://api.github.com/users/scotthasbrouck/following{/other_user}","gists_url":"https://api.github.com/users/scotthasbrouck/gists{/gist_id}","starred_url":"https://api.github.com/users/scotthasbrouck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scotthasbrouck/subscriptions","organizations_url":"https://api.github.com/users/scotthasbrouck/orgs","repos_url":"https://api.github.com/users/scotthasbrouck/repos","events_url":"https://api.github.com/users/scotthasbrouck/events{/privacy}","received_events_url":"https://api.github.com/users/scotthasbrouck/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-06T22:09:15Z","updated_at":"2015-02-10T19:12:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c526052db845bf6ec2295678bb7d320a8922bf9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8/commits","review_comments_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8/comments","review_comment_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/comments/{number}","comments_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/8/comments","statuses_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/statuses/075f4b8bd3f127f327a6ad2e66048f05b927cf3c","head":{"label":"BranchMetrics:implements_sms","ref":"implements_sms","sha":"075f4b8bd3f127f327a6ad2e66048f05b927cf3c","user":{"login":"BranchMetrics","id":7772941,"avatar_url":"https://avatars.githubusercontent.com/u/7772941?v=3","gravatar_id":"","url":"https://api.github.com/users/BranchMetrics","html_url":"https://github.com/BranchMetrics","followers_url":"https://api.github.com/users/BranchMetrics/followers","following_url":"https://api.github.com/users/BranchMetrics/following{/other_user}","gists_url":"https://api.github.com/users/BranchMetrics/gists{/gist_id}","starred_url":"https://api.github.com/users/BranchMetrics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BranchMetrics/subscriptions","organizations_url":"https://api.github.com/users/BranchMetrics/orgs","repos_url":"https://api.github.com/users/BranchMetrics/repos","events_url":"https://api.github.com/users/BranchMetrics/events{/privacy}","received_events_url":"https://api.github.com/users/BranchMetrics/received_events","type":"Organization","site_admin":false},"repo":{"id":25227902,"name":"Web-SDK","full_name":"BranchMetrics/Web-SDK","owner":{"login":"BranchMetrics","id":7772941,"avatar_url":"https://avatars.githubusercontent.com/u/7772941?v=3","gravatar_id":"","url":"https://api.github.com/users/BranchMetrics","html_url":"https://github.com/BranchMetrics","followers_url":"https://api.github.com/users/BranchMetrics/followers","following_url":"https://api.github.com/users/BranchMetrics/following{/other_user}","gists_url":"https://api.github.com/users/BranchMetrics/gists{/gist_id}","starred_url":"https://api.github.com/users/BranchMetrics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BranchMetrics/subscriptions","organizations_url":"https://api.github.com/users/BranchMetrics/orgs","repos_url":"https://api.github.com/users/BranchMetrics/repos","events_url":"https://api.github.com/users/BranchMetrics/events{/privacy}","received_events_url":"https://api.github.com/users/BranchMetrics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BranchMetrics/Web-SDK","description":"Branch Metrics Web SDK","fork":false,"url":"https://api.github.com/repos/BranchMetrics/Web-SDK","forks_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/forks","keys_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/teams","hooks_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/hooks","issue_events_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/events{/number}","events_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/events","assignees_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/assignees{/user}","branches_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/branches{/branch}","tags_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/tags","blobs_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/refs{/sha}","trees_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/statuses/{sha}","languages_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/languages","stargazers_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/stargazers","contributors_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/contributors","subscribers_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/subscribers","subscription_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/subscription","commits_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/commits{/sha}","git_commits_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/commits{/sha}","comments_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/comments{/number}","issue_comment_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/comments/{number}","contents_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/contents/{+path}","compare_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/merges","archive_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/downloads","issues_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues{/number}","pulls_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls{/number}","milestones_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/milestones{/number}","notifications_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/labels{/name}","releases_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/releases{/id}","created_at":"2014-10-14T21:41:36Z","updated_at":"2015-02-10T17:41:42Z","pushed_at":"2015-02-10T17:52:55Z","git_url":"git://github.com/BranchMetrics/Web-SDK.git","ssh_url":"git@github.com:BranchMetrics/Web-SDK.git","clone_url":"https://github.com/BranchMetrics/Web-SDK.git","svn_url":"https://github.com/BranchMetrics/Web-SDK","homepage":"http://branch.io","size":477,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":6,"default_branch":"master"}},"base":{"label":"BranchMetrics:v2","ref":"v2","sha":"c406dd815601d92d9e7e368d2844d30cdad5187c","user":{"login":"BranchMetrics","id":7772941,"avatar_url":"https://avatars.githubusercontent.com/u/7772941?v=3","gravatar_id":"","url":"https://api.github.com/users/BranchMetrics","html_url":"https://github.com/BranchMetrics","followers_url":"https://api.github.com/users/BranchMetrics/followers","following_url":"https://api.github.com/users/BranchMetrics/following{/other_user}","gists_url":"https://api.github.com/users/BranchMetrics/gists{/gist_id}","starred_url":"https://api.github.com/users/BranchMetrics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BranchMetrics/subscriptions","organizations_url":"https://api.github.com/users/BranchMetrics/orgs","repos_url":"https://api.github.com/users/BranchMetrics/repos","events_url":"https://api.github.com/users/BranchMetrics/events{/privacy}","received_events_url":"https://api.github.com/users/BranchMetrics/received_events","type":"Organization","site_admin":false},"repo":{"id":25227902,"name":"Web-SDK","full_name":"BranchMetrics/Web-SDK","owner":{"login":"BranchMetrics","id":7772941,"avatar_url":"https://avatars.githubusercontent.com/u/7772941?v=3","gravatar_id":"","url":"https://api.github.com/users/BranchMetrics","html_url":"https://github.com/BranchMetrics","followers_url":"https://api.github.com/users/BranchMetrics/followers","following_url":"https://api.github.com/users/BranchMetrics/following{/other_user}","gists_url":"https://api.github.com/users/BranchMetrics/gists{/gist_id}","starred_url":"https://api.github.com/users/BranchMetrics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BranchMetrics/subscriptions","organizations_url":"https://api.github.com/users/BranchMetrics/orgs","repos_url":"https://api.github.com/users/BranchMetrics/repos","events_url":"https://api.github.com/users/BranchMetrics/events{/privacy}","received_events_url":"https://api.github.com/users/BranchMetrics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BranchMetrics/Web-SDK","description":"Branch Metrics Web SDK","fork":false,"url":"https://api.github.com/repos/BranchMetrics/Web-SDK","forks_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/forks","keys_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/teams","hooks_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/hooks","issue_events_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/events{/number}","events_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/events","assignees_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/assignees{/user}","branches_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/branches{/branch}","tags_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/tags","blobs_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/refs{/sha}","trees_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/statuses/{sha}","languages_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/languages","stargazers_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/stargazers","contributors_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/contributors","subscribers_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/subscribers","subscription_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/subscription","commits_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/commits{/sha}","git_commits_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/git/commits{/sha}","comments_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/comments{/number}","issue_comment_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/comments/{number}","contents_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/contents/{+path}","compare_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/merges","archive_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/downloads","issues_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues{/number}","pulls_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls{/number}","milestones_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/milestones{/number}","notifications_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/labels{/name}","releases_url":"https://api.github.com/repos/BranchMetrics/Web-SDK/releases{/id}","created_at":"2014-10-14T21:41:36Z","updated_at":"2015-02-10T17:41:42Z","pushed_at":"2015-02-10T17:52:55Z","git_url":"git://github.com/BranchMetrics/Web-SDK.git","ssh_url":"git@github.com:BranchMetrics/Web-SDK.git","clone_url":"https://github.com/BranchMetrics/Web-SDK.git","svn_url":"https://github.com/BranchMetrics/Web-SDK","homepage":"http://branch.io","size":477,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8"},"html":{"href":"https://github.com/BranchMetrics/Web-SDK/pull/8"},"issue":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/8"},"comments":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/BranchMetrics/Web-SDK/statuses/075f4b8bd3f127f327a6ad2e66048f05b927cf3c"}}}}