Created
October 7, 2015 03:20
-
-
Save gasolin/9f3ba3e79dc86ee9c896 to your computer and use it in GitHub Desktop.
just work test sample for bug 1208205, don't take it directly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global loadBodyHTML*/ | |
'use strict'; | |
require('/shared/js/component_utils.js'); | |
require('/shared/elements/gaia_radio/script.js'); | |
requireApp('settings/shared/test/unit/load_body_html_helper.js'); | |
requireApp('settings/shared/test/unit/mocks/mock_navigator_moz_settings.js'); | |
suite('Improve browser os panel > ', function() { | |
var MockSettingsCache; | |
var ImproveBrowserOSPanel; | |
var realSettings; | |
var panel; | |
var modules = [ | |
'panels/improve_browser_os/panel' | |
]; | |
var map = { | |
'*': { | |
'modules/settings_cache': 'MockSettingsCache', | |
'modules/settings_panel': 'MockSettingsPanel' | |
} | |
}; | |
suiteSetup(function(done) { | |
realSettings = window.navigator.mozSettings; | |
window.navigator.mozSettings = MockNavigatorSettings; | |
// Create a new requirejs context | |
var requireCtx = testRequire([], map, function() {}); | |
// Define MockSettingsPanel | |
define('MockSettingsPanel', function() { | |
return function(options) { | |
return { | |
init: options.onInit.bind(options) | |
}; | |
}; | |
}); | |
// Define MockSettingsCache | |
MockSettingsCache = { | |
_settings: {}, | |
getSettings: function(callback) { | |
callback(this._settings); | |
} | |
}; | |
define('MockSettingsCache', function() { | |
return MockSettingsCache; | |
}); | |
requireCtx(modules, function(_ImproveBrowserOSPanel) { | |
ImproveBrowserOSPanel = _ImproveBrowserOSPanel; | |
done(); | |
}); | |
}); | |
suiteTeardown(function() { | |
window.navigator.mozSettings = realSettings; | |
}); | |
setup(function() { | |
loadBodyHTML('_improve_browser_os.html'); | |
panel = ImproveBrowserOSPanel(); | |
}); | |
teardown(function() { | |
document.body.innerHTML = ''; | |
}); | |
suite('share performance data toggle', function() { | |
test('the toggle should be enabled when not dog fooding', function() { | |
MockSettingsCache._settings = { | |
'debug.performance_data.dogfooding': null, | |
'metrics.selectedMetrics.level': 'Basic' | |
}; | |
panel.init(document.body); | |
var toggle = document.querySelector( | |
'#metrics-basic'); | |
}); | |
test('the toggle should be disabled when dog fooding', function() { | |
MockSettingsCache._settings = { | |
'debug.performance_data.dogfooding': true | |
}; | |
panel.init(document.body); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment