Skip to content

Commit 615b581

Browse files
committed
test(inc): ensure SemVer instanced passed as input are not modified
1 parent e7c3973 commit 615b581

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functions/inc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ test('increment versions test', (t) => {
1010
t.equal(found, wanted, `${cmd} === ${wanted}`)
1111

1212
const parsed = parse(pre, options)
13+
const parsedAsInput = parse(pre, options)
1314
if (wanted) {
1415
parsed.inc(what, id)
1516
t.equal(parsed.version, wanted, `${cmd} object version updated`)
1617
t.equal(parsed.raw, wanted, `${cmd} object raw field updated`)
18+
19+
const preIncObject = JSON.stringify(parsedAsInput)
20+
inc(parsedAsInput, what, options, id)
21+
const postIncObject = JSON.stringify(parsedAsInput)
22+
t.equal(
23+
postIncObject,
24+
preIncObject,
25+
`${cmd} didn't modify its input`
26+
)
1727
} else if (parsed) {
1828
t.throws(() => {
1929
parsed.inc(what, id)

0 commit comments

Comments
 (0)