|
@@ -1,9 +1,12 @@
|
|
|
-import { BrowserWindow } from 'electron/main';
|
|
|
+import { BrowserWindow, app } from 'electron/main';
|
|
|
import { shell } from 'electron/common';
|
|
|
import { closeAllWindows } from './window-helpers';
|
|
|
import { emittedOnce } from './events-helpers';
|
|
|
import * as http from 'http';
|
|
|
+import * as fs from 'fs-extra';
|
|
|
+import * as path from 'path';
|
|
|
import { AddressInfo } from 'net';
|
|
|
+import { expect } from 'chai';
|
|
|
|
|
|
describe('shell module', () => {
|
|
|
describe('shell.openExternal()', () => {
|
|
@@ -57,4 +60,21 @@ describe('shell module', () => {
|
|
|
]);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('shell.moveItemToTrash()', () => {
|
|
|
+ it('moves an item to the trash', async () => {
|
|
|
+ const dir = await fs.mkdtemp(path.resolve(app.getPath('temp'), 'electron-shell-spec-'));
|
|
|
+ const filename = path.join(dir, 'temp-to-be-deleted');
|
|
|
+ await fs.writeFile(filename, 'dummy-contents');
|
|
|
+ const result = shell.moveItemToTrash(filename);
|
|
|
+ expect(result).to.be.true();
|
|
|
+ expect(fs.existsSync(filename)).to.be.false();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('returns false when called with a nonexistent path', () => {
|
|
|
+ const filename = path.join(app.getPath('temp'), 'does-not-exist');
|
|
|
+ const result = shell.moveItemToTrash(filename);
|
|
|
+ expect(result).to.be.false();
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|