GitHub PullRequestReviewCommentEvent at 2014-04-11 14:19:56
Repository: gaia
Actor: lodr
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/11533929","id":11533929,"diff_hunk":"@@ -0,0 +1,205 @@\n+/* global MockCommon, MockCostControl, MockNavigatorMozMobileConnections,\n+          Widget, MockConfigManager, MockNavigatorMozIccManager,\n+          MockMozNetworkStats, AirplaneModeHelper, MocksHelper, Common\n+*/\n+'use strict';\n+\n+require('/test/unit/mock_moz_l10n.js');\n+require('/shared/test/unit/mocks/mock_lazy_loader.js');\n+require('/test/unit/mock_debug.js');\n+require('/js/utils/toolkit.js');\n+require('/test/unit/mock_common.js');\n+require('/shared/test/unit/load_body_html_helper.js');\n+require('/shared/test/unit/mocks/mock_settings_listener.js');\n+require('/shared/test/unit/mocks/mock_navigator_moz_mobile_connections.js');\n+require('/test/unit/mock_moz_network_stats.js');\n+require('/shared/test/unit/mocks/mock_navigator_moz_icc_manager.js');\n+require('/test/unit/mock_cost_control.js');\n+require('/test/unit/mock_config_manager.js');\n+require('/test/unit/mock_airplane_mode_helper.js');\n+require('/shared/js/lazy_loader.js');\n+require('/js/views/BalanceView.js');\n+require('/js/widget.js');\n+\n+var realMozMobileConnections,\n+    realMozL10n,\n+    realMozNetworkStats,\n+    realMozIccManager,\n+    realCommon;\n+\n+if (!window.navigator.mozNetworkStats) {\n+  window.navigator.mozNetworkStats = null;\n+}\n+\n+if (!window.navigator.mozIccManager) {\n+  window.navigator.mozIccManager = null;\n+}\n+\n+if (!window.navigator.mozMobileConnections) {\n+  window.navigator.mozMobileConnections = null;\n+}\n+\n+if (!window.navigator.mozL10n) {\n+  window.navigator.mozL10n = null;\n+}\n+\n+if (!window.Common) {\n+  window.Common = null;\n+}\n+\n+var MocksHelperForUnitTest = new MocksHelper([\n+  'LazyLoader',\n+  'AirplaneModeHelper',\n+  'ConfigManager',\n+  'CostControl',\n+  'SettingsListener'\n+]).init();\n+\n+suite('Application Startup Modes Test Suite >', function() {\n+\n+  MocksHelperForUnitTest.attachTestHelpers();\n+\n+  var fte, rightPanel, leftPanel;\n+  suiteSetup(function() {\n+\n+    realCommon = window.Common;\n+    window.Common = new MockCommon({ });\n+\n+    realMozMobileConnections = window.navigator.mozMobileConnections;\n+    window.navigator.mozMobileConnections = MockNavigatorMozMobileConnections;\n+\n+    realMozL10n = window.navigator.mozL10n;\n+    window.navigator.mozL10n = window.MockMozL10n;\n+\n+    realMozNetworkStats = window.navigator.mozNetworkStats;\n+    navigator.mozNetworkStats = MockMozNetworkStats;\n+\n+    realMozIccManager = window.navigator.mozIccManager;\n+    navigator.mozIccManager = window.MockNavigatorMozIccManager;\n+  });\n+\n+  setup(function() {\n+    navigator.mozIccManager = window.MockNavigatorMozIccManager;\n+    loadBodyHTML('/widget.html');\n+    fte = document.getElementById('fte-view');\n+    leftPanel = document.getElementById('left-panel');\n+    rightPanel = document.getElementById('right-panel');\n+    // Hide all panels\n+    fte.setAttribute('aria-hidden', 'true');\n+    leftPanel.setAttribute('aria-hidden', 'true');\n+    rightPanel.getAttribute('aria-hidden', 'true');\n+  });\n+\n+  teardown(function() {\n+    window.location.hash = '';\n+  });\n+\n+  suiteTeardown(function() {\n+    window.Common = realCommon;\n+    window.navigator.mozMobileConnections = realMozMobileConnections;\n+    window.navigator.mozL10n = realMozL10n;\n+    window.navigator.mozNetworkStats = realMozNetworkStats;\n+    window.navigator.mozIccManager = realMozIccManager;\n+  });\n+\n+  function loadDataSIMIccIdRequestFails(onsuccess, onerror) {\n+    setTimeout(function() {\n+      (typeof onerror === 'function') && onerror();\n+    }, 0);\n+  }\n+\n+  function setupCardState(icc) {\n+    window.Common = new MockCommon({ isValidICCID: true });\n+    window.CostControl = new MockCostControl();\n+    Common.dataSimIcc = icc;\n+  }\n+\n+  function setupConfig(applicationMode, ftePending) {\n+    window.ConfigManager = new MockConfigManager({\n+      fakeSettings: { fte: ftePending},\n+      applicationMode: applicationMode\n+    });\n+  }\n+\n+  function assertNoSimMessage() {\n+    assert.ok(fte.textContent.trim().contains('widget-no-sim2-meta'));\n+    assert.equal(fte.getAttribute('aria-hidden'), 'false');\n+    assert.equal(leftPanel.getAttribute('aria-hidden'), 'true');\n+    assert.equal(rightPanel.getAttribute('aria-hidden'), 'true');\n+  }\n+\n+  function assertAirplaneModeMessage() {\n+    assert.ok(fte.textContent.trim().contains('widget-airplane-mode-meta'));\n+    assert.equal(fte.getAttribute('aria-hidden'), 'false');\n+    assert.equal(leftPanel.getAttribute('aria-hidden'), 'true');\n+    assert.equal(rightPanel.getAttribute('aria-hidden'), 'true');\n+  }\n+\n+  test('Not exist a mandatory API', function() {\n+    window.navigator.mozIccManager = null;\n+    Widget.init();","path":"apps/costcontrol/test/unit/widget_startup_test.js","position":140,"original_position":140,"commit_id":"ffe65dda05213e9e3842e80c4466de9a0b27f09b","original_commit_id":"ffe65dda05213e9e3842e80c4466de9a0b27f09b","user":{"login":"lodr","id":757942,"avatar_url":"https://avatars.githubusercontent.com/u/757942?","gravatar_id":"284a643007ef8adc480a171b0a663e86","url":"https://api.github.com/users/lodr","html_url":"https://github.com/lodr","followers_url":"https://api.github.com/users/lodr/followers","following_url":"https://api.github.com/users/lodr/following{/other_user}","gists_url":"https://api.github.com/users/lodr/gists{/gist_id}","starred_url":"https://api.github.com/users/lodr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lodr/subscriptions","organizations_url":"https://api.github.com/users/lodr/orgs","repos_url":"https://api.github.com/users/lodr/repos","events_url":"https://api.github.com/users/lodr/events{/privacy}","received_events_url":"https://api.github.com/users/lodr/received_events","type":"User","site_admin":false},"body":"`init()` is not synchronous. You need some way to detect the function `showSIMError()` function was called. The best option is to expose the function in order to install a spy and assert on the spy's call arguments.","created_at":"2014-04-11T14:19:56Z","updated_at":"2014-04-11T14:19:56Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/18167#discussion_r11533929","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/18167","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/11533929"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/18167#discussion_r11533929"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/18167"}}}}