Skip to content

Commit

Permalink
fix: throw on bad version
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 14, 2023
1 parent 503a4e5 commit 16a021e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions functions/diff.js
@@ -1,8 +1,8 @@
const parse = require('./parse')
const SemVer = require('../classes/semver')

const diff = (version1, version2) => {
const v1 = parse(version1)
const v2 = parse(version2)
const v1 = new SemVer(version1)
const v2 = new SemVer(version2)
const comparison = v1.compare(v2)

if (comparison === 0) {
Expand Down
10 changes: 10 additions & 0 deletions test/functions/diff.js
Expand Up @@ -43,3 +43,13 @@ test('diff versions test', (t) => {

t.end()
})

test('throws on bad version', (t) => {
t.throws(() => {
diff('bad', '1.2.3')
}, {
message: 'Invalid Version: bad',
name: 'TypeError',
})
t.end()
})

0 comments on commit 16a021e

Please sign in to comment.