-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from electron/add-tests
add tests
- Loading branch information
Showing
4 changed files
with
85 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: node_js | ||
cache: | ||
directories: | ||
- ~/.npm | ||
notifications: | ||
email: false | ||
node_js: | ||
- '8' | ||
after_success: | ||
- npm run travis-deploy-once "npm run semantic-release" | ||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,61 @@ | ||
// const proxyquire = require('proxyquire') | ||
// const mock = require('mock-require') | ||
const updater = require('.') | ||
const repo = 'some-owner/some-repo' | ||
const electron = { | ||
app: { | ||
getVersion: () => { return '1.2.3' }, | ||
isReady: () => { return true }, | ||
on: (eventName) => { /* no-op */ } | ||
}, | ||
autoUpdater: { | ||
checkForUpdates: () => { /* no-op */ }, | ||
on: (eventName) => { /* no-op */ }, | ||
setFeedURL: () => { /* no-op */ } | ||
}, | ||
dialog: { | ||
showMessageBox: () => { /* no-op */ } | ||
} | ||
} | ||
|
||
// const updater = mock('./index.js', { | ||
// 'electron': { | ||
// app: {}, | ||
// autoUpdater: {}, | ||
// dialog: {} | ||
// } | ||
// }) | ||
test('exports a function', () => { | ||
expect(typeof updater).toBe('function') | ||
}) | ||
|
||
// TODO: Figure out how to mock require('electron') | ||
describe('repository', () => { | ||
test('is required', () => { | ||
expect(() => { | ||
updater({electron}) | ||
}).toThrowError('repo is required and should be in the format `owner/repo`') | ||
}) | ||
}) | ||
|
||
xtest('exports a function', () => { | ||
expect(typeof updater).toBe('function') | ||
describe('host', () => { | ||
test('must a valid HTTPS URL', () => { | ||
expect(() => { | ||
updater({repo, electron, host: 'http://example.com'}) | ||
}).toThrowError('host must be a valid HTTPS URL') | ||
}) | ||
}) | ||
|
||
describe('debug', () => { | ||
test('must be a boolean', () => { | ||
expect(() => { | ||
updater({repo, electron, debug: 'yep'}) | ||
}).toThrowError('debug must be a boolean') | ||
}) | ||
}) | ||
|
||
describe('updateInterval', () => { | ||
test('must be 30 seconds or more', () => { | ||
expect(() => { | ||
updater({repo, electron, updateInterval: '20 seconds'}) | ||
}).toThrowError('updateInterval must be `30 seconds` or more') | ||
}) | ||
|
||
test('must be a string', () => { | ||
expect(() => { | ||
updater({repo, electron, updateInterval: 3000}) | ||
}).toThrowError('updateInterval must be a human-friendly string interval like `90 seconds`') | ||
}) | ||
}) | ||
|
||
|