Skip to content

Commit

Permalink
Merge pull request #29 from electron-userland/tape
Browse files Browse the repository at this point in the history
Run tests via tape
  • Loading branch information
kevinsawicki authored Sep 12, 2016
2 parents 3ea4d4d + 85fad59 commit b6b4bea
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 60 deletions.
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.

0 comments on commit b6b4bea

Please sign in to comment.