Skip to content

Commit

Permalink
Fix loading and mocking old modules in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed May 11, 2016
1 parent 00026bb commit 713316e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "0.12"
- "5"

branches:
only:
Expand Down
9 changes: 6 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ test.before(() => {
writeFileSync: function () {},
readFileSync: function () {}
};
const electronMock = {
app: {getPath: function () {return '/temp';}},
screen: {getDisplayMatching: function () {}}
};
mockery.registerAllowables(['./', 'path', 'object-assign', 'deep-equal', 'sinon', './lib/keys.js', './lib/is_arguments.js']);
mockery.registerMock('app', {getPath: function () {return '/temp';}});
mockery.registerMock('screen', {getDisplayMatching: function () {}});
mockery.registerMock('electron', electronMock);
mockery.registerMock('mkdirp', {sync: function () {}});
mockery.registerMock('jsonfile', jsonfileMock);
mockery.enable({useCleanCache: true});
Expand Down Expand Up @@ -103,7 +106,7 @@ test('saves the state to the file system', t => {
const jsonfile = require('jsonfile');
sinon.spy(jsonfile, 'writeFileSync');

const screen = require('screen');
const screen = require('electron').screen;
sinon.stub(screen, 'getDisplayMatching').returns({bounds: screenBounds});

const state = require('./')({defaultWidth: 1000, defaultHeight: 2000});
Expand Down

0 comments on commit 713316e

Please sign in to comment.