Skip to content

Commit

Permalink
Fix ESLint warnings in installed-tests/
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Feb 12, 2025
1 parent 04361cf commit 55710f6
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 20 deletions.
3 changes: 1 addition & 2 deletions installed-tests/fixtures/components/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const MockMediaPlayer = GObject.registerClass({
/**
* Update the player with an object of properties and values.
*
* @param {Object} obj - A dictionary of properties
* @param {object} obj - A dictionary of properties
*/
update(obj) {
for (const [propertyName, propertyValue] of Object.entries(obj))
Expand Down Expand Up @@ -184,4 +184,3 @@ const Component = GObject.registerClass({
});

export default Component;

3 changes: 1 addition & 2 deletions installed-tests/fixtures/components/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ export default class MockSessionComponent {
/**
* Update the session with an object of properties and values.
*
* @param {Object} obj - A dictionary of properties
* @param {object} obj - A dictionary of properties
*/
update(obj) {
for (const [propertyName, propertyValue] of Object.entries(obj))
this[`_${propertyName}`] = propertyValue;
}
}

59 changes: 48 additions & 11 deletions installed-tests/fixtures/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ globalThis.HAVE_GNOME = true;
/*
* File Helpers
*/


/**
* Find the path to the datadir via the import path.
*
* @returns {string} The absolute datadir path
*/
function get_datadir() {
const thisFile = Gio.File.new_for_uri(import.meta.url);

Expand All @@ -45,21 +52,45 @@ function get_datadir() {
const DATA_PATH = get_datadir();


/**
* Convert a filename into a path within the datadir
*
* @param {string} filename - A filename
* @returns {string} An absolute path
*/
export function getDataPath(filename) {
return GLib.build_filenamev([DATA_PATH, filename]);
}


/**
* Convert a filename into a URI within the datadir
*
* @param {string} filename - A filename
* @returns {string} An absolute-path URI
*/
export function getDataUri(filename) {
return `file://${getDataPath(filename)}`;
}


/**
* Create a Gio.File object for a filename within the datadir
*
* @param {string} filename - A filename
* @returns {Gio.File} A File object representing the named file
*/
export function getDataFile(filename) {
return Gio.File.new_for_path(getDataPath(filename));
}


/**
* Read the contents of a file
*
* @param {string} filename - The file to load
* @returns {string} The file's contents as a UTF-8 string
*/
export function loadDataContents(filename) {
const path = getDataPath(filename);
const bytes = GLib.file_get_contents(path)[1];
Expand All @@ -84,6 +115,12 @@ Promise.idle = function (priority = GLib.PRIORITY_DEFAULT_IDLE) {
/*
* Identity Helpers
*/

/**
* Get a pseudo-random device type
*
* @returns {string} A GSConnect device type
*/
function getDeviceType() {
const types = [
'desktop',
Expand All @@ -99,8 +136,8 @@ function getDeviceType() {
/**
* Generate a pseudo-random device identity.
*
* @param {Object} params - Override parameters
* @return {Object} A pseudo-random identity packet
* @param {object} params - Override parameters
* @returns {object} A pseudo-random identity packet
*/
export function generateIdentity(params = {}) {
const identity = {
Expand Down Expand Up @@ -130,9 +167,9 @@ export function generateIdentity(params = {}) {
/**
* Check if @subset is a subset of @obj.
*
* @param {Object} obj - The haystack to compare with
* @param {Object} subset - The needle to search for
* @return {boolean} %true if the object is a subset
* @param {object} obj - The haystack to compare with
* @param {object} subset - The needle to search for
* @returns {boolean} %true if the object is a subset
*/
function isSubset(obj, subset) {
for (const [key, val] of Object.entries(subset)) {
Expand Down Expand Up @@ -176,7 +213,7 @@ function isSubset(obj, subset) {
* packet to handle. Note, the object must have an active jasmine spy.
*
* @param {string} type - A KDE Connect packet type
* @param {Object} [body] - Packet body properties
* @param {object} [body] - Packet body properties
*/
async function _awaitPacket(type, body = null) {
while (true) {
Expand All @@ -202,7 +239,7 @@ Plugin.prototype.awaitPacket = _awaitPacket;
/**
* Create temporary directories used by GSConnect.
*
* @return {string} The root temporary directory
* @returns {string} The root temporary directory
*/
function isolateDirectories() {
const tmpdir = GLib.Dir.make_tmp('gsconnect.XXXXXX');
Expand Down Expand Up @@ -291,10 +328,10 @@ export class TestRig {
* Connect the devices with `setConnected()`, pair them with `setPaired()`
* and load their plugins with `loadPlugins()`.
*
* @param {Object} [overrides] - Capability overrides
* @param {Object} overrides.localDevice - Local device overrides
* @param {Object} overrides.remoteDevice - Remote device overrides
* @return {Promise} A promise for the operation
* @param {object} [overrides] - Capability overrides
* @param {object} overrides.localDevice - Local device overrides
* @param {object} overrides.remoteDevice - Remote device overrides
* @returns {Promise} A promise for the operation
*/
prepare(overrides = {}) {
return new Promise((resolve, reject) => {
Expand Down
1 change: 0 additions & 1 deletion installed-tests/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//
// SPDX-License-Identifier: MPL-2.0

// eslint-disable-next-line no-unused-vars
export const getJasmineRequireObj = (function(jasmineGlobal) {
var jasmineRequire;

Expand Down
6 changes: 5 additions & 1 deletion installed-tests/suites/plugins/testContactsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const Packets = {
};


/**
* Mocked packet handling for the test device
*
* @param {*} packet - a KDE Connect protocol packet
*/
function handlePacket(packet) {
if (packet.type === 'kdeconnect.contacts.request_all_uids_timestamps') {
this.sendPacket(Packets.uidsResponse);
Expand Down Expand Up @@ -145,4 +150,3 @@ describe('The contacts plugin', function () {
expect(localPlugin._store.get_contact('valid')).toBeDefined();
});
});

6 changes: 5 additions & 1 deletion installed-tests/suites/plugins/testSftpPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const Packets = {
};


/**
* Mocked packet handling for the test device
*
* @param {*} packet - a KDE Connect protocol packet
*/
function handlePacket(packet) {
switch (packet.type) {
case 'kdeconnect.sftp.request':
Expand Down Expand Up @@ -119,4 +124,3 @@ describe('The sftp plugin', function () {
expect(localPlugin.device.get_action_enabled('unmount')).toBeFalse();
});
});

6 changes: 5 additions & 1 deletion installed-tests/suites/plugins/testSmsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ const Packets = {
};


/**
* Mocked packet handling for the test device
*
* @param {*} packet - a KDE Connect protocol packet
*/
function handlePacket(packet) {
switch (packet.type) {
case 'kdeconnect.sms.request_conversations':
Expand Down Expand Up @@ -275,4 +280,3 @@ describe('The sms plugin', function () {
expect(localPlugin.device.get_action_enabled(action)).toBeFalse();
});
});

6 changes: 5 additions & 1 deletion installed-tests/suites/plugins/testSystemvolumePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import * as Utils from '../fixtures/utils.js';


/**
* Mocked packet handling for the test device
*
* @param {*} packet - a KDE Connect protocol packet
*/
function handlePacket(packet) {
switch (packet.type) {
case 'kdeconnect.systemvolume':
Expand Down Expand Up @@ -122,4 +127,3 @@ describe('The systemvolume plugin', function () {
expect(localPlugin._mixer.lookup_sink(0).muted).toBeTrue();
});
});

0 comments on commit 55710f6

Please sign in to comment.