forked from sindresorhus/electron-store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixture.cjs
45 lines (33 loc) · 963 Bytes
/
fixture.cjs
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
35
36
37
38
39
40
41
42
43
44
45
'use strict';
const assert = require('assert');
const electron = require('electron');
// Prevent Electron from never exiting when an exception happens
process.on('uncaughtException', error => {
console.error('Exception:', error);
process.exit(1);
});
async function main() {
const Store = (await import('./index.js')).default;
const store = new Store({name: 'electron-store'});
const storeWithSchema = new Store({
name: 'electron-store-with-schema',
schema: {
foo: {
default: 42
}
}
});
store.set('unicorn', '🦄');
assert.strictEqual(store.get('unicorn'), '🦄');
store.delete('unicorn');
assert.strictEqual(store.get('unicorn'), undefined);
storeWithSchema.set('foo', 77);
assert.strictEqual(storeWithSchema.get('foo'), 77);
storeWithSchema.reset('foo');
assert.strictEqual(storeWithSchema.get('foo'), 42);
// To be checked in AVA
store.set('ava', '🚀');
console.log(store.path);
electron.app.quit();
}
main();