This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1073495 - merge pull request #27502 from fcampo:remember_default_…
…activity_1073495 to mozilla-b2g:master
- Loading branch information
Showing
19 changed files
with
1,034 additions
and
93 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use strict'; | ||
|
||
/* global DefaultActivityHelper, MockSettingsHelper, SettingsHelper */ | ||
|
||
require('/shared/js/default_activity_helper.js'); | ||
require('/shared/test/unit/mocks/mock_settings_helper.js'); | ||
|
||
suite('Default Activity Helper', function() { | ||
var realSettingsHelper; | ||
|
||
suiteSetup(function() { | ||
realSettingsHelper = window.SettingsHelper; | ||
window.SettingsHelper = MockSettingsHelper; | ||
}); | ||
|
||
suiteTeardown(function() { | ||
window.SettingsHelper = realSettingsHelper; | ||
}); | ||
|
||
suite('getDefaultConfig', function() { | ||
test('returns config if supported', function() { | ||
var config = DefaultActivityHelper.getDefaultConfig('view', 'url'); | ||
assert.ok(config); | ||
assert.equal(config.settingsId, 'activity.default.openurl'); | ||
}); | ||
|
||
test('returns undefined if not supported', function() { | ||
var config = DefaultActivityHelper.getDefaultConfig('aaa', 'bbbb'); | ||
assert.equal(config, undefined); | ||
}); | ||
}); | ||
|
||
suite('getDefaultAction', function(done) { | ||
test('setting is recovered for supported activity', function(done) { | ||
var settingsHelper = SettingsHelper('activity.default.openurl', null); | ||
settingsHelper.set('manifest'); | ||
DefaultActivityHelper.getDefaultAction('view', 'url').then((action) => { | ||
assert.equal(action, 'manifest'); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('cb is called with null if not supported', function(done) { | ||
DefaultActivityHelper.getDefaultAction('aaaa', 'bbb').then((action) => { | ||
assert.equal(action, null); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
suite('setDefaultAction', function(done) { | ||
test('setting is set for supported action', function(done) { | ||
var settingsHelper = SettingsHelper('activity.default.openurl', null); | ||
DefaultActivityHelper.setDefaultAction('view', 'url', 'testmanifest'); | ||
settingsHelper.get(function(value) { | ||
assert.equal(value, 'testmanifest'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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
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
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
Oops, something went wrong.