Skip to content

Commit

Permalink
fix up initialization of MergeDeep to account for ignorableFields (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
markjm authored May 15, 2024
1 parent f0bea72 commit f382e35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/mergeDeep.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const NAME_USERNAME_PROPERTY = item => NAME_FIELDS.find(prop => Object.prototype
const GET_NAME_USERNAME_PROPERTY = item => { if (NAME_USERNAME_PROPERTY(item)) return item[NAME_USERNAME_PROPERTY(item)] }

class MergeDeep {
constructor (log, github, ignorableFields, configvalidators = {}, overridevalidators = {}) {
constructor (log, github, ignorableFields = [], configvalidators = {}, overridevalidators = {}) {
this.log = log
this.github = github
this.ignorableFields = ignorableFields
Expand Down
9 changes: 8 additions & 1 deletion test/unit/lib/mergeDeep.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,14 @@ entries:
hasChanges: true
}
const ignorableFields = []
const mergeDeep = new MergeDeep(log, ignorableFields)
const mockReturnGitHubContext = jest.fn().mockReturnValue({
request: () => {},
});
const mergeDeep = new MergeDeep(
log,
mockReturnGitHubContext,
ignorableFields
)
const merged = mergeDeep.compareDeep(target, source)
console.log(`diffs ${JSON.stringify(merged, null, 2)}`)
expect(merged).toEqual(expected)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Validator Tests', () => {

try {
const ignorableFields = []
const mergeDeep = new MergeDeep(log, ignorableFields)
const mergeDeep = new MergeDeep(log, {}, ignorableFields)
mergeDeep.mergeDeep(baseconfig, overrideconfig)
} catch (err) {
expect(err).toBeDefined()
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('Validator Tests', () => {

try {
const ignorableFields = []
const mergeDeep = new MergeDeep(log, ignorableFields)
const mergeDeep = new MergeDeep(log, {}, ignorableFields)
mergeDeep.mergeDeep(baseconfig, overrideconfig)
} catch (err) {
expect(err).toBeDefined()
Expand Down

0 comments on commit f382e35

Please sign in to comment.