VulpesOS/gaia/apps/system/test/unit/app_test.js
OverSu b38dea0597 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.
2026-09-30 23:13:03 +02:00

84 lines
2.4 KiB
JavaScript
Executable file

/* global MocksHelper, BaseModule, MockApplications,
MockLazyLoader, App, Deferred */
'use strict';
require('/shared/test/unit/mocks/mock_lazy_loader.js');
requireApp('system/js/service.js');
requireApp('system/js/base_module.js');
requireApp('system/js/settings_core.js');
requireApp('system/js/launcher.js');
requireApp('system/js/core.js');
requireApp('system/test/unit/mock_applications.js');
requireApp('system/test/unit/deferred.js');
requireApp('system/js/app.js');
var mocksForLauncher = new MocksHelper([
'LazyLoader'
]).init();
suite('system/app', function() {
var subject;
mocksForLauncher.attachTestHelpers();
var FakeLauncher, FakeSettingsCore, FakeCore;
var fakeLauncherStartDeferred;
var fakeApplicationReadyDeferred;
var fakeLazyLoaderDeferred;
var fakeCoreStartDeferred;
suiteSetup(function() {
window.applications = MockApplications;
});
suiteTeardown(function() {
delete window.applications;
});
setup(function() {
fakeLazyLoaderDeferred = new Deferred();
fakeLauncherStartDeferred = new Deferred();
fakeApplicationReadyDeferred = new Deferred();
fakeCoreStartDeferred = new Deferred();
this.sinon.stub(MockLazyLoader, 'load').returns(
fakeLauncherStartDeferred.promise);
FakeCore = {
start: sinon.spy(function() {
return fakeCoreStartDeferred.promise;
})
};
FakeSettingsCore = {
start: this.sinon.spy()
};
FakeLauncher = {
start: sinon.spy(function() {
return fakeLauncherStartDeferred.promise;
})
};
subject = new App();
this.sinon.stub(MockApplications, 'waitForReady').returns(
fakeApplicationReadyDeferred.promise);
this.sinon.stub(BaseModule, 'instantiate', function(name) {
switch (name) {
case 'Core':
return FakeCore;
case 'SettingsCore':
return FakeSettingsCore;
case 'Launcher':
return FakeLauncher;
}
});
});
test('Should launch SettingsCore, Launcher, Core', function(done) {
subject.start().then(done, done);
fakeLazyLoaderDeferred.resolve();
fakeApplicationReadyDeferred.resolve();
fakeLauncherStartDeferred.resolve();
fakeCoreStartDeferred.resolve();
Promise.all([
fakeApplicationReadyDeferred.promise,
fakeLauncherStartDeferred.promise
]).then(function() {
assert.isDefined(window.core);
});
});
});