Skip to content

Commit

Permalink
Use fake spectron dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Apr 23, 2018
1 parent 055ac83 commit 1982a68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -56,7 +56,7 @@ script:
- set -e
- ./setup.sh
- yarn lint
- npm install electron spectron ava optimist tmp
- npm install electron spectron ava optimist tmp spectron-fake-dialog
- xvfb-run node_modules/.bin/ava --timeout=60s tests/electron_tests
- prove -Isrc/perl5 -r -j3 tests/perl_tests;
- utils/jb_run.js -p 9000 & sleep 2
Expand Down
7 changes: 1 addition & 6 deletions src/JBrowse/View/FileDialog.js
Expand Up @@ -143,12 +143,7 @@ return declare( null, {
else {
on( localFilesControl.uploader, 'click', function() {
var dialog = electronRequire('electron').remote.dialog;
var ret;
if(window.process.env.SPECTRON) {
ret = [window.process.cwd()+"/docs/tutorial/data_files/volvox.fa"];
} else {
ret = dialog.showOpenDialog({ properties: [ 'openFile','multiSelections' ]});
}
var ret = dialog.showOpenDialog({ properties: [ 'openFile','multiSelections' ]});
if( ret ) {
var paths = array.map( ret, function(replace) { return Util.replacePath(replace); });
resourceListControl.addURLs( paths );
Expand Down
9 changes: 8 additions & 1 deletion tests/electron_tests/spec.js
Expand Up @@ -5,6 +5,8 @@ import path from 'path';
import os from 'os';
var tmp = require('tmp');
var tmpobj = tmp.dirSync();
const fakeDialog = require('spectron-fake-dialog');


test.beforeEach(async t => {
t.context.app = new Application({
Expand All @@ -13,8 +15,13 @@ test.beforeEach(async t => {
env: {SPECTRON: '1'},
requireName: 'electronRequire'
});
fakeDialog.apply(t.context.app);

await t.context.app.start();
console.error(process.cwd()+"/docs/tutorial/data_files/volvox.fa");
await t.context.app.start()
.then(() =>
fakeDialog.mock([ { method: 'showOpenDialog', value: [process.cwd()+"/docs/tutorial/data_files/volvox.fa"] } ])
);
});

test.afterEach.always(async t => {
Expand Down

0 comments on commit 1982a68

Please sign in to comment.