Skip to content

Commit

Permalink
fix: Port tests to AVA (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipjscott authored Jan 6, 2019
1 parent 357a6d4 commit 6f56b26
Show file tree
Hide file tree
Showing 8 changed files with 8,030 additions and 6,272 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
test/out/
test/write.png
.nyc_output/
*.swo
*.swp
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ sudo: required
dist: trusty
node_js:
- '10'
- '9'
- '8'
after_success:
- npm run travis-deploy-once "npm run semantic-release"
Expand Down
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const { spawn } = require('child_process')
* @param {String} sizeStr A string in the form of '240x100' or '50%'
* @returns {Object} Object containing numeric values of the width and height
* of the thumbnail, or the scaling percentage
* @throws {Error} Throws on malformed size string
*/
function parseSize (sizeStr) {
const invalidSizeString = new Error('Invalid size string')
const percentRegex = /(\d+)%/g
const sizeRegex = /(\d+|\?)x(\d+|\?)/g
let size
Expand All @@ -27,7 +29,11 @@ function parseSize (sizeStr) {
height: sizeValues[2]
}
} else {
throw new Error('Invalid size argument')
throw invalidSizeString
}

if (size.width === null && size.height === null) {
throw invalidSizeString
}

return size
Expand Down Expand Up @@ -127,7 +133,7 @@ function ffmpegStreamExecute (path, args, rstream) {
* @param {Object} [config={}] A configuration object
* @param {String} [config.path='ffmpeg'] Path of the ffmpeg binary
* @param {String} [config.seek='00:00:00'] Time to seek for videos
* @returns {Promise} Resolves on completion
* @returns {Promise} Resolves on completion, or rejects on error
*/
function genThumbnail (input, output, size, config = {}) {
const ffmpegPath = config.path || process.env.FFMPEG_PATH || 'ffmpeg'
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simple-thumbnail",
"version": "0.0.0-development",
"description": "Produce thumbnails from images and videos",
"description": "Produce thumbnails from images, videos and URLs",
"main": "index.js",
"license": "MIT",
"author": "Philip Scott <[email protected]>",
Expand All @@ -21,7 +21,7 @@
"scripts": {
"fix": "standard --fix",
"lint": "standard",
"test": "standard && nyc mocha --timeout 15000",
"test": "standard && nyc ava",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"semantic-release": "semantic-release",
"travis-deploy-once": "travis-deploy-once --pro",
Expand All @@ -34,17 +34,14 @@
},
"devDependencies": {
"all-contributors-cli": "^5.4.1",
"array-flatten": "^2.1.1",
"chai": "^4.1.2",
"ava": "^1.0.1",
"coveralls": "^3.0.2",
"dirty-chai": "^2.0.1",
"fs-extra": "^7.0.0",
"ffmpeg-static": "^2.4.0",
"fs-extra": "^7.0.1",
"looks-same": "^3.3.0",
"mocha": "^5.2.0",
"nock": "^9.6.1",
"nyc": "^12.0.2",
"semantic-release": "^15.12.0",
"sinon": "^6.1.5",
"standard": "^12.0.1",
"travis-deploy-once": "^5.0.9"
}
Expand Down
Loading

0 comments on commit 6f56b26

Please sign in to comment.