Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
65
gaia/apps/system/test/unit/battery_icon_test.js
Executable file
65
gaia/apps/system/test/unit/battery_icon_test.js
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
/* global BatteryIcon, MockNavigatorBattery, MockL10n */
|
||||
'use strict';
|
||||
|
||||
requireApp('system/js/service.js');
|
||||
requireApp('system/js/base_ui.js');
|
||||
requireApp('system/js/base_icon.js');
|
||||
requireApp('system/js/battery_icon.js');
|
||||
requireApp('system/test/unit/mock_navigator_battery.js');
|
||||
require('/shared/test/unit/mocks/mock_l10n.js');
|
||||
|
||||
suite('system/BatteryIcon', function() {
|
||||
var subject, realMozL10n;
|
||||
|
||||
setup(function() {
|
||||
realMozL10n = navigator.mozL10n;
|
||||
navigator.mozL10n = MockL10n;
|
||||
MockNavigatorBattery.level = 0.95;
|
||||
MockNavigatorBattery.charging = false;
|
||||
subject = new BatteryIcon({
|
||||
_battery: MockNavigatorBattery
|
||||
});
|
||||
subject.start();
|
||||
subject.element = document.createElement('div');
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
navigator.mozL10n = realMozL10n;
|
||||
subject.stop();
|
||||
});
|
||||
|
||||
test('should not publish changed when there is no change', function() {
|
||||
subject.update();
|
||||
this.sinon.stub(subject, 'publish');
|
||||
subject.update();
|
||||
assert.isFalse(subject.publish.calledWith('changed'));
|
||||
});
|
||||
|
||||
test('should not publish iconchange when computed level does not change',
|
||||
function() {
|
||||
subject.update();
|
||||
MockNavigatorBattery.level = 0.95;
|
||||
this.sinon.stub(subject, 'publish');
|
||||
subject.update();
|
||||
|
||||
assert.isFalse(subject.publish.calledWith('changed'));
|
||||
});
|
||||
|
||||
test('should publish iconchange when battery changes', function() {
|
||||
subject.update();
|
||||
MockNavigatorBattery.level = 0.5;
|
||||
this.sinon.stub(subject, 'publish');
|
||||
subject.update();
|
||||
|
||||
assert.isTrue(subject.publish.calledWith('changed'));
|
||||
});
|
||||
|
||||
test('should publish iconchange when charging state changes', function() {
|
||||
subject.update();
|
||||
MockNavigatorBattery.charging = true;
|
||||
this.sinon.stub(subject, 'publish');
|
||||
subject.update();
|
||||
|
||||
assert.isTrue(subject.publish.calledWith('changed'));
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue