Skip to content

Commit

Permalink
test: refactored test suite to use mocks (conventional-changelog#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli authored Sep 7, 2020
1 parent a1c2053 commit 274f694
Show file tree
Hide file tree
Showing 6 changed files with 1,310 additions and 1,345 deletions.
12 changes: 8 additions & 4 deletions lib/updaters/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const path = require('path')
const JSON_BUMP_FILES = require('../../defaults').bumpFiles
const updatersByType = {
json: require('./types/json'),
'plain-text': require('./types/plain-text')
}
const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt']

function getUpdaterByType (type) {
try {
return require(`./types/${type}`)
} catch (e) {
throw Error(`Unable to locate updated for provided type (${type}).`)
const updater = updatersByType[type]
if (!updater) {
throw Error(`Unable to locate updater for provided type (${type}).`)
}
return updater
}

function getUpdaterByFilename (filename) {
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"fix": "eslint . --fix",
"posttest": "eslint .",
"test": "nyc mocha --timeout=30000 test.js",
"test": "nyc mocha --timeout=30000",
"test:unit": "mocha --exclude test/git.spec.js",
"release": "bin/cli.js"
},
"nyc": {
Expand Down Expand Up @@ -61,9 +62,10 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"mocha": "^8.0.0",
"mock-git": "^2.0.0",
"mock-fs": "^4.12.0",
"mockery": "^2.1.0",
"nyc": "^14.1.1",
"shelljs": "^0.8.4"
"shelljs": "^0.8.4",
"std-mocks": "^1.0.1"
}
}
Loading

0 comments on commit 274f694

Please sign in to comment.