Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests via tape #29

Merged
merged 6 commits into from
Sep 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.npmignore
.travis.yml
appveyor.yml
test*.js
test
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"electron-download": "cli.js"
},
"scripts": {
"test": "eslint . && node test.js && node test_symbols.js && node test_404.js && node test_with_checksum.js && echo PASSED"
"test": "tape test/*.js && eslint ."
},
"repository": {
"type": "git",
Expand All @@ -34,7 +34,8 @@
"eslint": "^3.2.0",
"eslint-config-standard": "^5.2.0",
"eslint-plugin-promise": "^2.0.0",
"eslint-plugin-standard": "^2.0.0"
"eslint-plugin-standard": "^2.0.0",
"tape": "^4.6.0"
},
"eslintConfig": {
"extends": "standard",
Expand Down
13 changes: 0 additions & 13 deletions test.js

This file was deleted.

9 changes: 9 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const fs = require('fs')

exports.verifyDownloadedZip = (t, err, zipPath) => {
t.error(err, 'Error should be null')
t.equal(fs.statSync(zipPath).isFile(), true, 'Zip path should exist')
t.notEqual(fs.statSync(zipPath).size, 0, 'Zip path should be non-empty')
}
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const download = require('..')
const test = require('tape')
const verifyDownloadedZip = require('./helpers').verifyDownloadedZip

test('Basic test', (t) => {
download({
version: '0.25.1',
arch: 'ia32',
platform: 'win32'
}, (err, zipPath) => {
verifyDownloadedZip(t, err, zipPath)
t.end()
})
})
18 changes: 18 additions & 0 deletions test/test_404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const download = require('..')
const fs = require('fs')
const test = require('tape')

test('404 test', (t) => {
download({
version: '0.25.1',
arch: 'ia32',
platform: 'darwin'
}, (err, zipPath) => {
if (!err) t.fail('Download should throw an error')
t.equal(fs.existsSync(zipPath), false, 'Zip path should not exist')
t.equal(err.message, 'Failed to find Electron v0.25.1 for darwin-ia32 at https://github.com/electron/electron/releases/download/v0.25.1/electron-v0.25.1-darwin-ia32.zip', 'Error message should contain version and URL')
t.end()
})
})
18 changes: 18 additions & 0 deletions test/test_symbols.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const download = require('..')
const test = require('tape')
const verifyDownloadedZip = require('./helpers').verifyDownloadedZip

test('Symbols test', (t) => {
download({
version: '0.26.1',
arch: 'x64',
platform: 'darwin',
symbols: true
}, (err, zipPath) => {
verifyDownloadedZip(t, err, zipPath)
t.ok(/-symbols\.zip$/.test(zipPath), 'Zip path should end with -symbols.zip')
t.end()
})
})
17 changes: 17 additions & 0 deletions test/test_with_checksum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const download = require('..')
const test = require('tape')
const verifyDownloadedZip = require('./helpers').verifyDownloadedZip

test('Checksum test', (t) => {
download({
version: '1.3.3',
arch: 'x64',
platform: 'win32',
symbols: true
}, (err, zipPath) => {
verifyDownloadedZip(t, err, zipPath)
t.end()
})
})
16 changes: 0 additions & 16 deletions test_404.js

This file was deleted.

14 changes: 0 additions & 14 deletions test_symbols.js

This file was deleted.

14 changes: 0 additions & 14 deletions test_with_checksum.js

This file was deleted.