Skip to content

Commit

Permalink
Port remaining imports, fix absolute imports
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Nov 14, 2023
1 parent a03085b commit 4b0090d
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 24 deletions.
3 changes: 2 additions & 1 deletion installed-tests/fixtures/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';

const Core = imports.service.core;
import Config from '../config.js';
const Core = await import(`file://${Config.PACKAGE_DATADIR}/service/core.js`);


/**
Expand Down
3 changes: 2 additions & 1 deletion installed-tests/fixtures/components/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import GObject from 'gi://GObject';

const MPRIS = imports.service.components.mpris;
import Config from '../../config.js';
const MPRIS = await import(`file://${Config.PACKAGE_DATADIR}/service/components/mpris.js`);


const MockMediaPlayer = GObject.registerClass({
Expand Down
6 changes: 3 additions & 3 deletions installed-tests/fixtures/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';

const Config = imports.config;
const DBus = imports.service.utils.dbus;
const MPRIS = imports.service.components.mpris;
import Config from '../config.js';
const DBus = await import(`file://${Config.PACKAGE_DATADIR}/service/utils/dbus.js`);
const MPRIS = await import(`file://${Config.PACKAGE_DATADIR}/service/components/mpris.js`);


/*
Expand Down
8 changes: 4 additions & 4 deletions installed-tests/fixtures/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ if (GLib.getenv('GSCONNECT_TEST')) {
}


await import(`${Config.PACKAGE_DATADIR}/service/init.js`);
const {default: Device} = await import(`${Config.PACKAGE_DATADIR}/service/device.js`);
const {default: Plugin} = await import(`${Config.PACKAGE_DATADIR}/service/plugin.js`);
await import(`file://${Config.PACKAGE_DATADIR}/service/init.js`);
const {default: Device} = await import(`file://${Config.PACKAGE_DATADIR}/service/device.js`);
const {default: Plugin} = await import(`file://${Config.PACKAGE_DATADIR}/service/plugin.js`);

const {ChannelService} = await import('./utils.js');

Expand Down Expand Up @@ -225,7 +225,7 @@ function isolateDirectories() {
* Patch in the mock components for plugin tests.
*/
export async function mockComponents() {
const Components = await import(`${Config.PACKAGE_DATADIR}/service/components/index.js`);
const Components = await import(`file://${Config.PACKAGE_DATADIR}/service/components/index.js`);
const MockComponents = await import('./components/index.js');

Components.acquire = function (name) {
Expand Down
5 changes: 3 additions & 2 deletions installed-tests/suites/backends/testLanBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import GLib from 'gi://GLib';

import * as Utils from '../fixtures/utils.js';

const Core = imports.service.core;
const Lan = imports.service.backends.lan;
import Config from '../config.js';
const Core = await import(`file://${Config.PACKAGE_DATADIR}/service/core.js`);
const Lan = await import(`file://${Config.PACKAGE_DATADIR}/service/backends/lan.js`);


describe('A LAN channel service', function () {
Expand Down
3 changes: 2 additions & 1 deletion installed-tests/suites/components/testClipboardComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import GLib from 'gi://GLib';

import '../fixtures/utils.js';

const {Clipboard} = imports.service.components.clipboard;
import Config from '../config.js';
const {default: Clipboard} = await import(`file://${Config.PACKAGE_DATADIR}/service/components/clipboard.js`);


describe('The Clipboard component', function () {
Expand Down
7 changes: 4 additions & 3 deletions installed-tests/suites/components/testMprisComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ import GLib from 'gi://GLib';
import '../fixtures/utils.js';
import MockPlayer from '../fixtures/mpris.js';

const MPRIS = imports.service.components.mpris;
import Config from '../config.js';
const {default: Manager} = await import(`file://${Config.PACKAGE_DATADIR}/service/components/mpris.js`);


// Prevent auto-loading
MPRIS.Manager.prototype._loadPlayers = function () {};
Manager.prototype._loadPlayers = function () {};


describe('The MPRIS component', function () {
let manager;
let player;

beforeAll(function () {
manager = new MPRIS.Manager();
manager = new Manager();
player = new MockPlayer(GLib.uuid_string_random());
});

Expand Down
2 changes: 1 addition & 1 deletion installed-tests/suites/core/testDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import GLib from 'gi://GLib';
import Config from '../config.js';
import * as Utils from '../fixtures/utils.js';

const {default: Device} = await import(`${Config.PACKAGE_DATADIR}/service/device.js`);
const {default: Device} = await import(`file://${Config.PACKAGE_DATADIR}/service/device.js`);


describe('A device constructed from a packet', function () {
Expand Down
3 changes: 2 additions & 1 deletion installed-tests/suites/core/testManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import GLib from 'gi://GLib';

import * as Utils from '../fixtures/utils.js';

const {Manager} = imports.service.manager;
import Config from '../config.js';
const {default: Manager} = await import(`file://${Config.PACKAGE_DATADIR}/service/manager.js`);


// TODO: * device management
Expand Down
3 changes: 2 additions & 1 deletion installed-tests/suites/core/testPacket.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import '../fixtures/utils.js';

const Core = imports.service.core;
import Config from '../config.js';
const Core = await import(`file://${Config.PACKAGE_DATADIR}/service/core.js`);


/*
Expand Down
6 changes: 3 additions & 3 deletions installed-tests/suites/core/testPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import GObject from 'gi://GObject';
import Config from '../config.js';
import * as Utils from '../fixtures/utils.js';

const {default: Device} = await import(`${Config.PACKAGE_DATADIR}/service/device.js`);
const Components = await import(`${Config.PACKAGE_DATADIR}/service/components/index.js`);
const {default: PluginBase} = await import(`${Config.PACKAGE_DATADIR}/service/plugin.js`);
const {default: Device} = await import(`file://${Config.PACKAGE_DATADIR}/service/device.js`);
const Components = await import(`file://${Config.PACKAGE_DATADIR}/service/components/index.js`);
const {default: PluginBase} = await import(`file://${Config.PACKAGE_DATADIR}/service/plugin.js`);


/*
Expand Down
5 changes: 4 additions & 1 deletion installed-tests/suites/plugins/testContactsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import GLib from 'gi://GLib';

import * as Utils from '../fixtures/utils.js';

import Config from '../config.js';


const VCards = {
valid: Utils.loadDataContents('vcard-valid.vcf'),
Expand Down Expand Up @@ -134,7 +136,8 @@ describe('The contacts plugin', function () {
while (localPlugin._store.contacts.length)
await Promise.idle();

imports.service.plugins.contacts.EBookContacts = null;
const contactPlugin = await import(`file://${Config.PACKAGE_DATADIR}/service/plugins/contacts.js`);
contactPlugin.EBookContacts = null;

localPlugin._requestVCards(['valid']);

Expand Down
4 changes: 3 additions & 1 deletion installed-tests/suites/plugins/testSftpPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

import * as Utils from '../fixtures/utils.js';
const {Plugin} = imports.service.plugin;

import Config from '../config.js';
const {default: Plugin} = await import(`file://${Config.PACKAGE_DATADIR}/service/plugin.js`);


const Packets = {
Expand Down
2 changes: 1 addition & 1 deletion src/service/plugins/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Contacts from '../components/contacts.js';
/*
* We prefer libebook's vCard parser if it's available
*/
let EBookContacts;
export let EBookContacts;

try {
EBookContacts = (await import('gi://EBookContacts')).default;
Expand Down

0 comments on commit 4b0090d

Please sign in to comment.