{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/34034366","id":34034366,"diff_hunk":"@@ -0,0 +1,521 @@\n+/* global LazyLoader, FormUI, MockL10n */\n+\n+'use strict';\n+\n+require('/shared/test/unit/mocks/mock_l10n.js');\n+require('/shared/test/unit/load_body_html_helper.js');\n+require('/shared/js/lazy_loader.js');\n+require('/shared/elements/config.js');\n+require('/shared/js/component_utils.js');\n+require('/shared/elements/gaia_subheader/script.js');\n+require('/shared/elements/gaia-header/dist/gaia-header.js');\n+\n+\n+\n+requireApp('communications/contacts/js/utilities/performance_helper.js');\n+require('/shared/js/l10n.js');\n+requireApp('communications/contacts/js/navigation.js');\n+requireApp('communications/contacts/services/contacts.js');\n+require('/shared/js/l10n_date.js');\n+require('/shared/js/contact_photo_helper.js');\n+require('/shared/js/contacts/utilities/templates.js');\n+requireApp('communications/contacts/js/contacts_tag.js');\n+requireApp('communications/contacts/js/tag_options.js');\n+require('/shared/js/text_normalizer.js');\n+require('/shared/js/contacts/import/utilities/status.js');\n+require('/shared/js/contacts/utilities/dom.js');\n+require('/shared/js/contacts/import/utilities/misc.js');\n+\n+requireApp('communications/contacts/views/form/js/form_ui.js');\n+\n+/*\n+ * NOTE: How tests are working:\n+ * Every suite will try to test all actions, step by step, that\n+ * you can execute in the form.\n+ *\n+ * Take into account that all tests within a suite rely on the former\n+ * one, so we are keeping the state (in order to execute several UI\n+ * actions in a linear manner).\n+ *\n+ * Keep in mind this behaviour!\n+ *\n+ */\n+\n+\n+\n+suite('FormUI', function() {\n+\n+  var realMozL10n;\n+\n+  suiteSetup(function(done) {\n+\n+    realMozL10n = navigator.mozL10n;\n+    navigator.mozL10n = MockL10n;\n+\n+    // Load HTML\n+    loadBodyHTML('/contacts/views/form/form.html');\n+\n+    // Add hook to template to \"head\"\n+    var importHook = document.createElement('link');\n+    importHook.id = 'form-import-link';\n+    importHook.setAttribute('rel', 'import');\n+    importHook.setAttribute('href', '/contacts/elements/form.html');\n+    document.head.appendChild(importHook);\n+\n+    // Fill the HTML\n+    LazyLoader.load([document.getElementById('view-contact-form')], function() {\n+      FormUI.init();\n+      done();\n+    });\n+  });\n+\n+  suiteTeardown(function() {\n+    navigator.mozL10n = realMozL10n;\n+    realMozL10n = null;\n+    var importHook =\n+      document.querySelector('link[rel=import][id=\"form-import-link\"]');\n+    document.head.removeChild(importHook);\n+    document.body.innerHTML = '';\n+    window.FormUI = null;\n+  });\n+\n+  suite('Close button', function() {\n+    test(' > must dispatch an event when clicked', function(done) {\n+      window.addEventListener('close-ui', function() {\n+        done();\n+      });\n+\n+      var clickEvent = new CustomEvent('action');\n+      document.querySelector('#contact-form-header').dispatchEvent(clickEvent);\n+    });\n+  });\n+\n+\n+  suite('Phone number', function() {\n+    var contact = {\n+      tel: ['123456789']\n+    };\n+\n+    test(' > Add one phone number by \"render\" method', function() {\n+      FormUI.render(contact);\n+      var inputsRendered =\n+        document.querySelectorAll(\n+          'input[data-field=\"value\"]:not([value=\"\"]):not([value=\"#value#\"])'\n+        );\n+      inputsRendered = Array.prototype.filter.call(\n+        inputsRendered,\n+        function(element) {\n+          return element.id.startsWith('number');\n+        }\n+      );\n+\n+      assert.equal(inputsRendered.length, 1);\n+      assert.equal(inputsRendered[0].value, contact.tel[0]);\n+    });\n+\n+    test(' > Save button must be enabled', function() {\n+      var saveButton = document.querySelector('#save-button');\n+      assert.equal(saveButton.getAttribute('disabled'), null);\n+    });\n+\n+    test(' > Reset in given phone number', function() {\n+      var inputs =\n+        document.querySelectorAll(","path":"apps/communications/contacts/test/unit/views/form/form_ui_test.js","position":123,"original_position":123,"commit_id":"6eb3c748f51bcb28a399adeab20f9a23bb358462","original_commit_id":"6eb3c748f51bcb28a399adeab20f9a23bb358462","user":{"login":"arcturus","id":60801,"avatar_url":"https://avatars.githubusercontent.com/u/60801?v=3","gravatar_id":"","url":"https://api.github.com/users/arcturus","html_url":"https://github.com/arcturus","followers_url":"https://api.github.com/users/arcturus/followers","following_url":"https://api.github.com/users/arcturus/following{/other_user}","gists_url":"https://api.github.com/users/arcturus/gists{/gist_id}","starred_url":"https://api.github.com/users/arcturus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcturus/subscriptions","organizations_url":"https://api.github.com/users/arcturus/orgs","repos_url":"https://api.github.com/users/arcturus/repos","events_url":"https://api.github.com/users/arcturus/events{/privacy}","received_events_url":"https://api.github.com/users/arcturus/received_events","type":"User","site_admin":false},"body":"Should we have an utility function to wrap this querySelectorAll? It will add some readability:\r\n```\r\nvar inputs = getInputs();\r\n```","created_at":"2015-07-07T12:39:07Z","updated_at":"2015-07-07T12:39:07Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/30694#discussion_r34034366","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/34034366"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/30694#discussion_r34034366"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694","id":38360664,"html_url":"https://github.com/mozilla-b2g/gaia/pull/30694","diff_url":"https://github.com/mozilla-b2g/gaia/pull/30694.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/30694.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30694","number":30694,"state":"open","locked":false,"title":"Bug 1175575 - Create basic 'new' activity not tied to contacts.js in a separate .html r=arcturus","user":{"login":"borjasalguero","id":1785537,"avatar_url":"https://avatars.githubusercontent.com/u/1785537?v=3","gravatar_id":"","url":"https://api.github.com/users/borjasalguero","html_url":"https://github.com/borjasalguero","followers_url":"https://api.github.com/users/borjasalguero/followers","following_url":"https://api.github.com/users/borjasalguero/following{/other_user}","gists_url":"https://api.github.com/users/borjasalguero/gists{/gist_id}","starred_url":"https://api.github.com/users/borjasalguero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borjasalguero/subscriptions","organizations_url":"https://api.github.com/users/borjasalguero/orgs","repos_url":"https://api.github.com/users/borjasalguero/repos","events_url":"https://api.github.com/users/borjasalguero/events{/privacy}","received_events_url":"https://api.github.com/users/borjasalguero/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-23T17:17:54Z","updated_at":"2015-07-07T12:39:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5101aba233e2a87db5d3e287c813b8ff819d5bdd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30694/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/6eb3c748f51bcb28a399adeab20f9a23bb358462","head":{"label":"borjasalguero:form_activity_final","ref":"form_activity_final","sha":"6eb3c748f51bcb28a399adeab20f9a23bb358462","user":{"login":"borjasalguero","id":1785537,"avatar_url":"https://avatars.githubusercontent.com/u/1785537?v=3","gravatar_id":"","url":"https://api.github.com/users/borjasalguero","html_url":"https://github.com/borjasalguero","followers_url":"https://api.github.com/users/borjasalguero/followers","following_url":"https://api.github.com/users/borjasalguero/following{/other_user}","gists_url":"https://api.github.com/users/borjasalguero/gists{/gist_id}","starred_url":"https://api.github.com/users/borjasalguero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borjasalguero/subscriptions","organizations_url":"https://api.github.com/users/borjasalguero/orgs","repos_url":"https://api.github.com/users/borjasalguero/repos","events_url":"https://api.github.com/users/borjasalguero/events{/privacy}","received_events_url":"https://api.github.com/users/borjasalguero/received_events","type":"User","site_admin":false},"repo":{"id":4470618,"name":"gaia","full_name":"borjasalguero/gaia","owner":{"login":"borjasalguero","id":1785537,"avatar_url":"https://avatars.githubusercontent.com/u/1785537?v=3","gravatar_id":"","url":"https://api.github.com/users/borjasalguero","html_url":"https://github.com/borjasalguero","followers_url":"https://api.github.com/users/borjasalguero/followers","following_url":"https://api.github.com/users/borjasalguero/following{/other_user}","gists_url":"https://api.github.com/users/borjasalguero/gists{/gist_id}","starred_url":"https://api.github.com/users/borjasalguero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borjasalguero/subscriptions","organizations_url":"https://api.github.com/users/borjasalguero/orgs","repos_url":"https://api.github.com/users/borjasalguero/repos","events_url":"https://api.github.com/users/borjasalguero/events{/privacy}","received_events_url":"https://api.github.com/users/borjasalguero/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/borjasalguero/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project","fork":true,"url":"https://api.github.com/repos/borjasalguero/gaia","forks_url":"https://api.github.com/repos/borjasalguero/gaia/forks","keys_url":"https://api.github.com/repos/borjasalguero/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/borjasalguero/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/borjasalguero/gaia/teams","hooks_url":"https://api.github.com/repos/borjasalguero/gaia/hooks","issue_events_url":"https://api.github.com/repos/borjasalguero/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/borjasalguero/gaia/events","assignees_url":"https://api.github.com/repos/borjasalguero/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/borjasalguero/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/borjasalguero/gaia/tags","blobs_url":"https://api.github.com/repos/borjasalguero/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/borjasalguero/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/borjasalguero/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/borjasalguero/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/borjasalguero/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/borjasalguero/gaia/languages","stargazers_url":"https://api.github.com/repos/borjasalguero/gaia/stargazers","contributors_url":"https://api.github.com/repos/borjasalguero/gaia/contributors","subscribers_url":"https://api.github.com/repos/borjasalguero/gaia/subscribers","subscription_url":"https://api.github.com/repos/borjasalguero/gaia/subscription","commits_url":"https://api.github.com/repos/borjasalguero/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/borjasalguero/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/borjasalguero/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/borjasalguero/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/borjasalguero/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/borjasalguero/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/borjasalguero/gaia/merges","archive_url":"https://api.github.com/repos/borjasalguero/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/borjasalguero/gaia/downloads","issues_url":"https://api.github.com/repos/borjasalguero/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/borjasalguero/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/borjasalguero/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/borjasalguero/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/borjasalguero/gaia/labels{/name}","releases_url":"https://api.github.com/repos/borjasalguero/gaia/releases{/id}","created_at":"2012-05-28T13:04:39Z","updated_at":"2015-04-13T11:14:39Z","pushed_at":"2015-07-07T10:29:51Z","git_url":"git://github.com/borjasalguero/gaia.git","ssh_url":"git@github.com:borjasalguero/gaia.git","clone_url":"https://github.com/borjasalguero/gaia.git","svn_url":"https://github.com/borjasalguero/gaia","homepage":"https://wiki.mozilla.org/B2G","size":915659,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"0013b96faedf3ce20375b4dc7997e96c00579ca3","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","created_at":"2011-09-03T01:38:46Z","updated_at":"2015-07-05T22:37:46Z","pushed_at":"2015-07-07T12:11:25Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1651324,"stargazers_count":1948,"watchers_count":1948,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2370,"mirror_url":null,"open_issues_count":1055,"forks":2370,"open_issues":1055,"watchers":1948,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/30694"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30694"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30694/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30694/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/6eb3c748f51bcb28a399adeab20f9a23bb358462"}}}}