Skip to content

Instantly share code, notes, and snippets.

@etiennesegonzac
Created August 19, 2014 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etiennesegonzac/aa42670ebeaf33c39680 to your computer and use it in GitHub Desktop.
Save etiennesegonzac/aa42670ebeaf33c39680 to your computer and use it in GitHub Desktop.
Update Manager roaming test with promise
test('should handle clicking download when using data connection ' +
'in the first time',
function(done) {
MockNavigatorSettings.mSettings['ril.data.roaming_enabled'] = false;
var getSpy = this.sinon.spy(UpdateManager, '_getDataRoamingSetting');
UpdateManager.downloadDialog.dataset.nowifi = true;
var evt = document.createEvent('MouseEvents');
evt.initEvent('click', true, true);
UpdateManager.requestDownloads(evt);
getSpy.lastCall.returnValue.then(function() {
var css = UpdateManager.downloadViaDataConnectionDialog.classList;
var titleL10nId =
UpdateManager.downloadViaDataConnectionTitle
.getAttribute('data-l10n-id');
var messageL10nId =
UpdateManager.downloadViaDataConnectionMessage
.getAttribute('data-l10n-id');
assert.isTrue(css.contains('visible'));
assert.equal(titleL10nId, 'downloadUpdatesViaDataConnection');
assert.equal(messageL10nId,
'downloadUpdatesViaDataConnectionMessage2');
}).then(done, done);
});
test('should handle clicking download when using data ' +
'connection roaming in the first time',
function(done) {
UpdateManager.downloadDialog.dataset.nowifi = true;
MockNavigatorSettings.mSettings['ril.data.roaming_enabled'] = true;
var getSpy = this.sinon.spy(UpdateManager, '_getDataRoamingSetting');
var evt = document.createEvent('MouseEvents');
evt.initEvent('click', true, true);
UpdateManager.requestDownloads(evt);
getSpy.lastCall.returnValue.then(function() {
var css = UpdateManager.downloadViaDataConnectionDialog.classList;
var titleL10nId =
UpdateManager.downloadViaDataConnectionTitle
.getAttribute('data-l10n-id');
var messageL10nId =
UpdateManager.downloadViaDataConnectionMessage
.getAttribute('data-l10n-id');
assert.isTrue(css.contains('visible'));
assert.equal(titleL10nId,
'downloadUpdatesViaDataRoamingConnection');
assert.equal(messageL10nId,
'downloadUpdatesViaDataRoamingConnectionMessage');
}).then(done, done);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment