Skip to content

Commit

Permalink
fix: don't mutate default options of Seller
Browse files Browse the repository at this point in the history
  • Loading branch information
ert78gb committed Oct 19, 2023
1 parent 36a3d8d commit 78dc213
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Seller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultOptions = {

export class Seller {
constructor (options) {
this._options = merge.recursive(defaultOptions, options || {})
this._options = merge.recursive(true, defaultOptions, options || {})
}

_generateXML (indentLevel) {
Expand Down
12 changes: 12 additions & 0 deletions tests/seller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ describe('Seller', function () {
it('should set _options property', function () {
expect(seller).to.have.property('_options').that.is.an('object')
})

it('should not mutate options', function () {
const seller = new Seller({})
const expected = {
_options: {
bank: {},
email: {}
}
}

expect(seller).to.be.deep.equal(expected)
})
})

describe('_generateXML', function () {
Expand Down

0 comments on commit 78dc213

Please sign in to comment.