{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/43087031","id":43087031,"diff_hunk":"@@ -8,47 +15,178 @@ suite('Root', function() {\n   };\n   var modules = [\n     'panels/root/root',\n-    'MockLazyLoader'\n+    'MockLazyLoader',\n+    'shared_mocks/mock_navigator_moz_settings'\n   ];\n \n-  suiteSetup(function(done) {\n+  setup(function(done) {\n     this.MockLazyLoader = {\n       load: function(scripts, callback) { setTimeout(callback); }\n     };\n \n     var requireCtx = testRequire([], map, function() {});\n+    loadBodyHTML('_root.html');\n+\n     define('MockLazyLoader', function() {\n       return this.MockLazyLoader;\n     }.bind(this));\n \n-    requireCtx(modules, function(Root) {\n+    requireCtx(modules, function(Root, MockLazyLoader, MockNavigatorSettings) {\n+      realMobileConnections = navigator.mozMobileConnections;\n+      realSettings = navigator.mozSettings;\n+      navigator.mozSettings = MockNavigatorSettings;\n \n-      this.Root = Root;\n+      panel = Root();\n       done();\n-    }.bind(this));\n+    });\n+  });\n+\n+  teardown(function() {\n+    navigator.mozSettings = realSettings;\n+    navigator.mozMobileConnections = realMobileConnections;\n   });\n \n   suite('init', function() {\n-    var sandbox;\n     var fakeTimer;\n-    var root;\n \n     setup(function() {\n-      sandbox = sinon.sandbox.create();\n       fakeTimer = sinon.useFakeTimers();\n-      root = this.Root();\n-      sandbox.stub(root, '_loadScripts');\n-      root.init();\n+      this.sinon.stub(panel, '_loadScripts');\n+      panel.init(document.body);\n     });\n \n     teardown(function() {\n-      sandbox.restore();\n       fakeTimer.restore();\n     });\n \n     test('_loadScripts should be called', function() {\n       fakeTimer.tick();\n-      sinon.assert.called(root._loadScripts);\n+      assert.ok(panel._loadScripts.called);\n+    });\n+  });\n+\n+  suite('should show/hide nfc item correctly', function() {\n+    var realNfc;\n+    var nfcItem;\n+\n+    setup(function() {\n+      realNfc = navigator.mozNfc;\n+      nfcItem = document.querySelector('.nfc-settings');\n+    });\n+\n+    teardown(function() {\n+      navigator.mozNfc = realNfc;\n+    });\n+\n+    test('nfc is available', function() {\n+      navigator.mozNfc = {'aa': 'bb'};\n+      panel.init(document.body);\n+      assert.isFalse(nfcItem.hidden);\n+    });\n+\n+    test('nfc is not available', function() {\n+      navigator.mozNfc = null;\n+      panel.init(document.body);\n+      assert.isTrue(nfcItem.hidden);\n+    });\n+  });\n+\n+  suite('should show/hide sim items correctly', function() {\n+    var callSettingsItem;\n+    var dataConnectivityItem;\n+    var messagingItem;\n+    var simSecurityItem;\n+    var simCardManagerItem;\n+\n+    test('no mobile connections', function() {\n+      navigator.mozMobileConnections = null;\n+      panel.init(document.body);\n+      callSettingsItem = document.getElementById('call-settings');\n+      dataConnectivityItem = document.getElementById('data-connectivity');\n+      messagingItem = document.getElementById('messaging-settings');\n+      simSecurityItem = document.getElementById('simSecurity-settings');\n+      simCardManagerItem = document.getElementById('simCardManager-settings');\n+      assert.isTrue(callSettingsItem.hidden);\n+      assert.isTrue(dataConnectivityItem.hidden);\n+      assert.isTrue(messagingItem.hidden);\n+      assert.isTrue(simSecurityItem.hidden);\n+      assert.isTrue(simCardManagerItem.hidden);\n+    });\n+\n+    test('single sim', function() {\n+      navigator.mozMobileConnections = {\n+        length: 1\n+      };\n+      panel.init(document.body);\n+      callSettingsItem = document.getElementById('call-settings');\n+      dataConnectivityItem = document.getElementById('data-connectivity');\n+      messagingItem = document.getElementById('messaging-settings');\n+      simSecurityItem = document.getElementById('simSecurity-settings');\n+      simCardManagerItem = document.getElementById('simCardManager-settings');\n+      assert.isFalse(callSettingsItem.hidden);\n+      assert.isFalse(dataConnectivityItem.hidden);\n+      assert.isFalse(messagingItem.hidden);\n+      assert.isFalse(simSecurityItem.hidden);\n+      assert.isTrue(simCardManagerItem.hidden);\n+    });\n+\n+    test('multiple sims', function() {\n+      navigator.mozMobileConnections = {\n+        length: 2\n+      };\n+      panel.init(document.body);\n+      callSettingsItem = document.getElementById('call-settings');\n+      dataConnectivityItem = document.getElementById('data-connectivity');\n+      messagingItem = document.getElementById('messaging-settings');\n+      simSecurityItem = document.getElementById('simSecurity-settings');\n+      simCardManagerItem = document.getElementById('simCardManager-settings');\n+      assert.isFalse(callSettingsItem.hidden);\n+      assert.isFalse(dataConnectivityItem.hidden);\n+      assert.isFalse(messagingItem.hidden);\n+      assert.isTrue(simSecurityItem.hidden);\n+      assert.isFalse(simCardManagerItem.hidden);\n+    });\n+  });\n+\n+  suite('should show/hide developer menu item correctly', function() {\n+    var developerMenuItem;\n+\n+    setup(function() {\n+      MockNavigatorSettings.mSetup();\n+    });\n+\n+    teardown(function() {\n+      MockNavigatorSettings.mTeardown();\n+    });\n+\n+    test('developer menu is enabled', function(done) {\n+      MockNavigatorSettings.mSet({\n+        'developer.menu.enabled': true\n+      });\n+      panel.init(document.body);\n+      developerMenuItem =\n+        document.querySelector('[data-show-name=\"developer.menu.enabled\"]');\n+      panel._showDeveloperMenuItem().then(function() {\n+        assert.isFalse(developerMenuItem.hidden);\n+      }, function() {\n+        // This function does not reject.\n+        assert.isTrue(false);\n+      }).then(done, done);\n+    });\n+\n+    test('developer menu is disabled', function(done) {\n+      MockNavigatorSettings.mSet({\n+        'developer.menu.enabled': false\n+      });\n+      panel.init(document.body);\n+      developerMenuItem =\n+        document.querySelector('[data-show-name=\"developer.menu.enabled\"]');\n+      panel._showDeveloperMenuItem().then(function() {\n+        assert.isTrue(developerMenuItem.hidden);\n+      }, function() {\n+        // This function does not reject.\n+        assert.isTrue(false);","path":"apps/settings/test/unit/panels/root/root_test.js","position":201,"original_position":201,"commit_id":"2e4fe0f179ddd4c249aae9ceab0b340842e17c44","original_commit_id":"2e4fe0f179ddd4c249aae9ceab0b340842e17c44","user":{"login":"yzen","id":561275,"avatar_url":"https://avatars.githubusercontent.com/u/561275?v=3","gravatar_id":"","url":"https://api.github.com/users/yzen","html_url":"https://github.com/yzen","followers_url":"https://api.github.com/users/yzen/followers","following_url":"https://api.github.com/users/yzen/following{/other_user}","gists_url":"https://api.github.com/users/yzen/gists{/gist_id}","starred_url":"https://api.github.com/users/yzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yzen/subscriptions","organizations_url":"https://api.github.com/users/yzen/orgs","repos_url":"https://api.github.com/users/yzen/repos","events_url":"https://api.github.com/users/yzen/events{/privacy}","received_events_url":"https://api.github.com/users/yzen/received_events","type":"User","site_admin":false},"body":"lets add second argument describing what the failure means","created_at":"2015-10-27T06:09:29Z","updated_at":"2015-10-27T06:09:29Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/32583#discussion_r43087031","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/43087031"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/32583#discussion_r43087031"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583","id":48159836,"html_url":"https://github.com/mozilla-b2g/gaia/pull/32583","diff_url":"https://github.com/mozilla-b2g/gaia/pull/32583.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/32583.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32583","number":32583,"state":"open","locked":false,"title":"Bug 1216435 - remove RootPanelHandler from startup.js, r=yzen","user":{"login":"gasolin","id":748808,"avatar_url":"https://avatars.githubusercontent.com/u/748808?v=3","gravatar_id":"","url":"https://api.github.com/users/gasolin","html_url":"https://github.com/gasolin","followers_url":"https://api.github.com/users/gasolin/followers","following_url":"https://api.github.com/users/gasolin/following{/other_user}","gists_url":"https://api.github.com/users/gasolin/gists{/gist_id}","starred_url":"https://api.github.com/users/gasolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasolin/subscriptions","organizations_url":"https://api.github.com/users/gasolin/orgs","repos_url":"https://api.github.com/users/gasolin/repos","events_url":"https://api.github.com/users/gasolin/events{/privacy}","received_events_url":"https://api.github.com/users/gasolin/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-20T06:00:12Z","updated_at":"2015-10-27T06:09:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7533f8514cf634a9f5111f74571ef1ad614c8a8b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583/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/32583/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/2e4fe0f179ddd4c249aae9ceab0b340842e17c44","head":{"label":"gasolin:removeroothandler","ref":"removeroothandler","sha":"2e4fe0f179ddd4c249aae9ceab0b340842e17c44","user":{"login":"gasolin","id":748808,"avatar_url":"https://avatars.githubusercontent.com/u/748808?v=3","gravatar_id":"","url":"https://api.github.com/users/gasolin","html_url":"https://github.com/gasolin","followers_url":"https://api.github.com/users/gasolin/followers","following_url":"https://api.github.com/users/gasolin/following{/other_user}","gists_url":"https://api.github.com/users/gasolin/gists{/gist_id}","starred_url":"https://api.github.com/users/gasolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasolin/subscriptions","organizations_url":"https://api.github.com/users/gasolin/orgs","repos_url":"https://api.github.com/users/gasolin/repos","events_url":"https://api.github.com/users/gasolin/events{/privacy}","received_events_url":"https://api.github.com/users/gasolin/received_events","type":"User","site_admin":false},"repo":{"id":8349595,"name":"gaia","full_name":"gasolin/gaia","owner":{"login":"gasolin","id":748808,"avatar_url":"https://avatars.githubusercontent.com/u/748808?v=3","gravatar_id":"","url":"https://api.github.com/users/gasolin","html_url":"https://github.com/gasolin","followers_url":"https://api.github.com/users/gasolin/followers","following_url":"https://api.github.com/users/gasolin/following{/other_user}","gists_url":"https://api.github.com/users/gasolin/gists{/gist_id}","starred_url":"https://api.github.com/users/gasolin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasolin/subscriptions","organizations_url":"https://api.github.com/users/gasolin/orgs","repos_url":"https://api.github.com/users/gasolin/repos","events_url":"https://api.github.com/users/gasolin/events{/privacy}","received_events_url":"https://api.github.com/users/gasolin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gasolin/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 https://wiki.mozilla.org/Release_Management/B2G_Landing","fork":true,"url":"https://api.github.com/repos/gasolin/gaia","forks_url":"https://api.github.com/repos/gasolin/gaia/forks","keys_url":"https://api.github.com/repos/gasolin/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gasolin/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gasolin/gaia/teams","hooks_url":"https://api.github.com/repos/gasolin/gaia/hooks","issue_events_url":"https://api.github.com/repos/gasolin/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/gasolin/gaia/events","assignees_url":"https://api.github.com/repos/gasolin/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/gasolin/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/gasolin/gaia/tags","blobs_url":"https://api.github.com/repos/gasolin/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gasolin/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gasolin/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/gasolin/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gasolin/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/gasolin/gaia/languages","stargazers_url":"https://api.github.com/repos/gasolin/gaia/stargazers","contributors_url":"https://api.github.com/repos/gasolin/gaia/contributors","subscribers_url":"https://api.github.com/repos/gasolin/gaia/subscribers","subscription_url":"https://api.github.com/repos/gasolin/gaia/subscription","commits_url":"https://api.github.com/repos/gasolin/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/gasolin/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/gasolin/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/gasolin/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/gasolin/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/gasolin/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gasolin/gaia/merges","archive_url":"https://api.github.com/repos/gasolin/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gasolin/gaia/downloads","issues_url":"https://api.github.com/repos/gasolin/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/gasolin/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/gasolin/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/gasolin/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gasolin/gaia/labels{/name}","releases_url":"https://api.github.com/repos/gasolin/gaia/releases{/id}","created_at":"2013-02-22T03:20:25Z","updated_at":"2015-05-06T02:30:34Z","pushed_at":"2015-10-27T06:03:45Z","git_url":"git://github.com/gasolin/gaia.git","ssh_url":"git@github.com:gasolin/gaia.git","clone_url":"https://github.com/gasolin/gaia.git","svn_url":"https://github.com/gasolin/gaia","homepage":"https://wiki.mozilla.org/B2G","size":966810,"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":"63c4256bd726b83d06e4935aa7fadfb3f711db67","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-10-26T01:49:34Z","pushed_at":"2015-10-27T06:06:09Z","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":1676193,"stargazers_count":1992,"watchers_count":1992,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2493,"mirror_url":null,"open_issues_count":1249,"forks":2493,"open_issues":1249,"watchers":1992,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/32583"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32583"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32583/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32583/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/32583/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/2e4fe0f179ddd4c249aae9ceab0b340842e17c44"}}}}