Skip to content

Commit

Permalink
WIP: Migrate tests to ES modules
Browse files Browse the repository at this point in the history
The Jasmine port isn't ideal, but this should be good to merge.
  • Loading branch information
retrixe committed Apr 4, 2024
1 parent d5644aa commit 0797a56
Show file tree
Hide file tree
Showing 38 changed files with 180 additions and 213 deletions.
16 changes: 7 additions & 9 deletions installed-tests/fixtures/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';

const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;

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


/**
Expand All @@ -24,7 +22,7 @@ const TRANSFER_MAX = 2764;
* A simple IP-based backend for tests. This should ostensibly be kept up to
* date with backends/lan.js as it is essentially a clone without the TLS parts.
*/
var ChannelService = GObject.registerClass({
export const ChannelService = GObject.registerClass({
GTypeName: 'GSConnectMockChannelService',
Properties: {
'port': GObject.ParamSpec.uint(
Expand Down Expand Up @@ -347,7 +345,7 @@ var ChannelService = GObject.registerClass({
/**
* A simple IP-based channel for tests
*/
var Channel = GObject.registerClass({
export const Channel = GObject.registerClass({
GTypeName: 'GSConnectMockChannel',
}, class MockChannel extends Core.Channel {

Expand Down
8 changes: 4 additions & 4 deletions installed-tests/fixtures/components/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import GObject from 'gi://GObject';

const {GObject} = imports.gi;


var Component = GObject.registerClass({
const Component = GObject.registerClass({
GTypeName: 'MockClipboard',
Properties: {
'text': GObject.ParamSpec.string(
Expand Down Expand Up @@ -36,3 +34,5 @@ var Component = GObject.registerClass({
}
});

export default Component;

13 changes: 13 additions & 0 deletions installed-tests/fixtures/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: GSConnect Developers https://github.com/GSConnect
//
// SPDX-License-Identifier: GPL-2.0-or-later

export {default as clipboard} from './clipboard.js';
export {default as input} from './input.js';
export {default as mpris} from './mpris.js';
export {default as notification} from './notification.js';
export {default as pulseaudio} from './pulseaudio.js';
export {default as session} from './session.js';
export {default as sound} from './sound.js';
export {default as upower} from './upower.js';

6 changes: 2 additions & 4 deletions installed-tests/fixtures/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';


var Component = class {
export default class Component {
clickPointer() {}

doubleclickPointer() {}
Expand All @@ -19,5 +17,5 @@ var Component = class {
scrollPointer() {}

pressKeys() {}
};
}

10 changes: 6 additions & 4 deletions installed-tests/fixtures/components/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import GObject from 'gi://GObject';

const {GObject} = imports.gi;
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 Expand Up @@ -96,7 +96,7 @@ const MockMediaPlayer = GObject.registerClass({
});


var Component = GObject.registerClass({
const Component = GObject.registerClass({
GTypeName: 'MockMPRISManager',
Signals: {
'player-added': {
Expand Down Expand Up @@ -183,3 +183,5 @@ var Component = GObject.registerClass({
}
});

export default Component;

9 changes: 5 additions & 4 deletions installed-tests/fixtures/components/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';

const {Gio, GLib, GObject} = imports.gi;


var Component = GObject.registerClass({
const Component = GObject.registerClass({
GTypeName: 'GSConnectMockNotificationListener',
Signals: {
'notification-added': {
Expand All @@ -23,3 +22,5 @@ var Component = GObject.registerClass({
}
});

export default Component;

9 changes: 4 additions & 5 deletions installed-tests/fixtures/components/pulseaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import GObject from 'gi://GObject';

const Tweener = imports.tweener.tweener;

const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;


class MockStream {
constructor(mixer, id) {
Expand Down Expand Up @@ -100,7 +97,7 @@ class MockStream {
}


var Component = GObject.registerClass({
const Component = GObject.registerClass({
GTypeName: 'GSConnectMockMixer',
Signals: {
'output-added': {
Expand Down Expand Up @@ -232,3 +229,5 @@ var Component = GObject.registerClass({
}
});

export default Component;

6 changes: 2 additions & 4 deletions installed-tests/fixtures/components/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';


var Component = class MockSession {
export default class MockSessionComponent {
get idle() {
if (this._idle === undefined)
this._idle = false;
Expand Down Expand Up @@ -34,5 +32,5 @@ var Component = class MockSession {
for (const [propertyName, propertyValue] of Object.entries(obj))
this[`_${propertyName}`] = propertyValue;
}
};
}

9 changes: 4 additions & 5 deletions installed-tests/fixtures/components/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';

const {Gio, GLib} = imports.gi;


var Component = class MockPlayer {
export default class MockPlayerComponent {

constructor() {
this._playing = new Set();
Expand Down Expand Up @@ -60,5 +59,5 @@ var Component = class MockPlayer {
this._playing.delete(cancellable);
}
}
};
}

8 changes: 4 additions & 4 deletions installed-tests/fixtures/components/upower.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import GObject from 'gi://GObject';

const {GObject} = imports.gi;


var Component = GObject.registerClass({
const Component = GObject.registerClass({
GTypeName: 'GSConnectMockBattery',
Signals: {
'changed': {flags: GObject.SignalFlags.RUN_FIRST},
Expand Down Expand Up @@ -50,3 +48,5 @@ var Component = GObject.registerClass({
}
});

export default Component;

16 changes: 9 additions & 7 deletions installed-tests/fixtures/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later

'use strict';
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';

const {Gio, GLib, GObject} = imports.gi;

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 All @@ -18,7 +17,7 @@ const MPRISIface = Config.DBUS.lookup_interface('org.mpris.MediaPlayer2');
const MPRISPlayerIface = Config.DBUS.lookup_interface('org.mpris.MediaPlayer2.Player');


var MockPlayer = GObject.registerClass({
const MockPlayer = GObject.registerClass({
GTypeName: 'GSConnectMockPlayer',
}, class MockPlayer extends MPRIS.Player {

Expand Down Expand Up @@ -123,3 +122,6 @@ var MockPlayer = GObject.registerClass({
}
}
});

export default MockPlayer;

Loading

0 comments on commit 0797a56

Please sign in to comment.