build: enable JS semicolons (#22783)

This commit is contained in:
Samuel Attard 2020-03-20 13:28:31 -07:00 committed by GitHub
parent 24e21467b9
commit 5d657dece4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 21512 additions and 21510 deletions

View file

@ -6,70 +6,70 @@
//
// See https://pypi.python.org/pypi/python-dbusmock to read about dbusmock.
import { expect } from 'chai'
import * as dbus from 'dbus-native'
import { app } from 'electron'
import { ifdescribe } from './spec-helpers'
import { promisify } from 'util'
import { expect } from 'chai';
import * as dbus from 'dbus-native';
import { app } from 'electron';
import { ifdescribe } from './spec-helpers';
import { promisify } from 'util';
const skip = process.platform !== 'linux' ||
process.arch === 'ia32' ||
process.arch.indexOf('arm') === 0 ||
!process.env.DBUS_SESSION_BUS_ADDRESS
!process.env.DBUS_SESSION_BUS_ADDRESS;
ifdescribe(!skip)('Notification module (dbus)', () => {
let mock: any, Notification, getCalls: any, reset: any
const realAppName = app.name
const realAppVersion = app.getVersion()
const appName = 'api-notification-dbus-spec'
const serviceName = 'org.freedesktop.Notifications'
let mock: any, Notification, getCalls: any, reset: any;
const realAppName = app.name;
const realAppVersion = app.getVersion();
const appName = 'api-notification-dbus-spec';
const serviceName = 'org.freedesktop.Notifications';
before(async () => {
// init app
app.name = appName
app.setDesktopName(`${appName}.desktop`)
app.name = appName;
app.setDesktopName(`${appName}.desktop`);
// init DBus
const path = '/org/freedesktop/Notifications'
const iface = 'org.freedesktop.DBus.Mock'
console.log(`session bus: ${process.env.DBUS_SESSION_BUS_ADDRESS}`)
const bus = dbus.sessionBus()
const service = bus.getService(serviceName)
const getInterface = promisify(service.getInterface.bind(service))
mock = await getInterface(path, iface)
getCalls = promisify(mock.GetCalls.bind(mock))
reset = promisify(mock.Reset.bind(mock))
})
const path = '/org/freedesktop/Notifications';
const iface = 'org.freedesktop.DBus.Mock';
console.log(`session bus: ${process.env.DBUS_SESSION_BUS_ADDRESS}`);
const bus = dbus.sessionBus();
const service = bus.getService(serviceName);
const getInterface = promisify(service.getInterface.bind(service));
mock = await getInterface(path, iface);
getCalls = promisify(mock.GetCalls.bind(mock));
reset = promisify(mock.Reset.bind(mock));
});
after(async () => {
// cleanup dbus
if (reset) await reset()
if (reset) await reset();
// cleanup app
app.setName(realAppName)
app.setVersion(realAppVersion)
})
app.setName(realAppName);
app.setVersion(realAppVersion);
});
describe(`Notification module using ${serviceName}`, () => {
function onMethodCalled (done: () => void) {
function cb (name: string) {
console.log(`onMethodCalled: ${name}`)
console.log(`onMethodCalled: ${name}`);
if (name === 'Notify') {
mock.removeListener('MethodCalled', cb)
console.log('done')
done()
mock.removeListener('MethodCalled', cb);
console.log('done');
done();
}
}
return cb
return cb;
}
function unmarshalDBusNotifyHints (dbusHints: any) {
const o: Record<string, any> = {}
const o: Record<string, any> = {};
for (const hint of dbusHints) {
const key = hint[0]
const value = hint[1][1][0]
o[key] = value
const key = hint[0];
const value = hint[1][1][0];
o[key] = value;
}
return o
return o;
}
function unmarshalDBusNotifyArgs (dbusArgs: any) {
@ -81,13 +81,13 @@ ifdescribe(!skip)('Notification module (dbus)', () => {
body: dbusArgs[4][1][0],
actions: dbusArgs[5][1][0],
hints: unmarshalDBusNotifyHints(dbusArgs[6][1][0])
}
};
}
before(done => {
mock.on('MethodCalled', onMethodCalled(done))
mock.on('MethodCalled', onMethodCalled(done));
// lazy load Notification after we listen to MethodCalled mock signal
Notification = require('electron').Notification
Notification = require('electron').Notification;
const n = new Notification({
title: 'title',
subtitle: 'subtitle',
@ -95,19 +95,19 @@ ifdescribe(!skip)('Notification module (dbus)', () => {
replyPlaceholder: 'replyPlaceholder',
sound: 'sound',
closeButtonText: 'closeButtonText'
})
n.show()
})
});
n.show();
});
it(`should call ${serviceName} to show notifications`, async () => {
const calls = await getCalls()
expect(calls).to.be.an('array').of.lengthOf.at.least(1)
const calls = await getCalls();
expect(calls).to.be.an('array').of.lengthOf.at.least(1);
const lastCall = calls[calls.length - 1]
const methodName = lastCall[1]
expect(methodName).to.equal('Notify')
const lastCall = calls[calls.length - 1];
const methodName = lastCall[1];
expect(methodName).to.equal('Notify');
const args = unmarshalDBusNotifyArgs(lastCall[2])
const args = unmarshalDBusNotifyArgs(lastCall[2]);
expect(args).to.deep.equal({
app_name: appName,
replaces_id: 0,
@ -120,7 +120,7 @@ ifdescribe(!skip)('Notification module (dbus)', () => {
'desktop-entry': appName,
urgency: 1
}
})
})
})
})
});
});
});
});