2020-02-08 23:26:57 +01:00
|
|
|
import * as electron from 'electron';
|
|
|
|
import { expect } from 'chai';
|
2020-07-25 02:02:37 +02:00
|
|
|
import { Context } from 'mocha';
|
2019-11-18 22:38:51 +01:00
|
|
|
import rewiremock from 'rewiremock';
|
|
|
|
|
|
|
|
import 'mocha';
|
2019-10-05 03:09:34 +02:00
|
|
|
import { Application } from 'spectron';
|
2019-10-11 23:10:30 +02:00
|
|
|
import packageJson from '../package.json';
|
2019-10-05 03:09:34 +02:00
|
|
|
|
2020-02-08 23:26:57 +01:00
|
|
|
rewiremock.disable();
|
|
|
|
|
2020-04-10 05:12:14 +02:00
|
|
|
describe('Application @slow', function () {
|
2019-10-12 16:26:34 +02:00
|
|
|
this.timeout(20000);
|
2019-10-05 03:09:34 +02:00
|
|
|
|
2020-07-25 02:02:37 +02:00
|
|
|
interface IApplicationContext extends Context {
|
|
|
|
app: Application;
|
|
|
|
}
|
|
|
|
|
|
|
|
before(function (this, done): void {
|
|
|
|
const context = this as IApplicationContext;
|
|
|
|
context.app = new Application({
|
|
|
|
// @ts-ignore this does give the path to electron executable when this script is running outside of electron (which it does in the test files)
|
|
|
|
path: ((electron as unknown) as { default: string }).default,
|
2019-10-05 03:09:34 +02:00
|
|
|
args: [packageJson.main],
|
|
|
|
});
|
2020-07-25 02:02:37 +02:00
|
|
|
context.app
|
|
|
|
.start()
|
|
|
|
.then(() => done())
|
|
|
|
.catch((reason) => done(reason));
|
2019-10-05 03:09:34 +02:00
|
|
|
});
|
|
|
|
|
2020-07-25 02:02:37 +02:00
|
|
|
after(function (this) {
|
|
|
|
const context = this as IApplicationContext;
|
|
|
|
if (context.app && context.app.isRunning()) {
|
|
|
|
return context.app.stop();
|
2019-10-05 03:09:34 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-07-25 02:02:37 +02:00
|
|
|
it('shows an initial window', function (this: Context) {
|
|
|
|
const context = this as IApplicationContext;
|
|
|
|
return context.app.client.getWindowCount().then((count: number) => {
|
2019-10-10 19:44:39 +02:00
|
|
|
expect(count).to.be.gte(1);
|
2019-10-05 03:09:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|