-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
test.js
34 lines (29 loc) · 979 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import fs from 'node:fs';
import path from 'node:path';
import electron from 'electron';
import test from 'ava';
import {execa} from 'execa';
// See https://github.com/sindresorhus/conf for more extensive tests
const run = async file => {
const {stdout} = await execa(electron, [file], {
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
ELECTRON_NO_ATTACH_CONSOLE: true,
},
});
return stdout.trim();
};
test('main', async t => {
const storagePath = await run('fixture.js');
t.deepEqual(JSON.parse(fs.readFileSync(storagePath, 'utf8')), {ava: '🚀'});
fs.unlinkSync(storagePath);
});
test('cwd option', async t => {
const result = await run('fixture-cwd.js');
const [defaultPath, storagePath, storagePath2] = result.split('\n');
t.is(storagePath, path.join(defaultPath, 'foo/config.json'));
t.is(storagePath2, path.join(import.meta.dirname, 'bar/config.json'));
fs.unlinkSync(storagePath);
fs.unlinkSync(storagePath2);
});