Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
deermichel committed Apr 1, 2022
1 parent 701a76d commit 5c80f29
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
7 changes: 7 additions & 0 deletions spec-main/api-app-spec.ts
Expand Up @@ -228,6 +228,13 @@ describe('app module', () => {
expect(code1).to.equal(0);
});

it.only('returns true when setting non-existent user data folder', async function () {
const appPath = path.join(fixturesPath, 'api', 'singleton-userdata');
const instance = cp.spawn(process.execPath, [appPath]);
const [code] = await emittedOnce(instance, 'exit');
expect(code).to.equal(0);
});

async function testArgumentPassing (testArgs: SingleInstanceLockTestArgs) {
const appPath = path.join(fixturesPath, 'api', 'singleton-data');
const first = cp.spawn(process.execPath, [appPath, ...testArgs.args]);
Expand Down
12 changes: 12 additions & 0 deletions spec/fixtures/api/singleton-userdata/main.js
@@ -0,0 +1,12 @@
const { app } = require('electron');
const fs = require('fs');
const path = require('path');

// non-existing user data folder should not break requestSingleInstanceLock()
// ref: https://github.com/electron/electron/issues/33547
const userDataFolder = path.join(app.getPath('home'), 'singleton-userdata');
fs.rmSync(userDataFolder, { force: true, recursive: true });
app.setPath('userData', userDataFolder);

const gotTheLock = app.requestSingleInstanceLock();
app.exit(gotTheLock ? 0 : 1);
4 changes: 4 additions & 0 deletions spec/fixtures/api/singleton-userdata/package.json
@@ -0,0 +1,4 @@
{
"name": "electron-test-singleton-userdata",
"main": "main.js"
}
8 changes: 0 additions & 8 deletions spec/fixtures/api/singleton/main.js
@@ -1,17 +1,9 @@
const { app } = require('electron');
const fs = require('fs');
const path = require('path');

app.whenReady().then(() => {
console.log('started'); // ping parent
});

// non-existing user data folder should not break requestSingleInstanceLock()
// ref: https://github.com/electron/electron/issues/33547
const userDataFolder = path.join(app.getPath('home'), 'electron-userData');
fs.rmSync(userDataFolder, { force: true, recursive: true });
app.setPath('userData', userDataFolder);

const gotTheLock = app.requestSingleInstanceLock();

app.on('second-instance', (event, args, workingDirectory) => {
Expand Down

0 comments on commit 5c80f29

Please sign in to comment.