Skip to content

Commit

Permalink
Fix issue where data isn't overwritten with multiple calls to setup
Browse files Browse the repository at this point in the history
  • Loading branch information
BenPatterson2 authored and JasonAllenCorns committed Jul 28, 2021
1 parent e72714e commit 27c9efb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/brie.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const brie = module.exports = (function () {
Object.assign(functionalCriteria, optCriteria);
features = optFeatures;
overrides = optOverrides;
Object.assign(data, optContext);
data = optContext
rulesEngine.setup({
criteria: functionalCriteria,
features: features
Expand Down
36 changes: 36 additions & 0 deletions test/helpers/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,41 @@ module.exports = function () {
});
assert(!!(bSetup));
});

it("replaces data when called twice", function () {
const fakeNumber = '8675309'
const features = {
allowId:{
criteria: [{
allowValues: {
trait: "aId",
values: [
fakeNumber
]
}
}]
}
}

const b1 = brie.setup({
data: {
aId: fakeNumber
},
overrides: {},
features,
});

assert.deepEqual(b1.get('allowId'), true)

const b2 = b1.setup({
data: {
wrongId: "555555"
},
overrides: {},
features,
});

assert.deepEqual(b2.get('allowId'), false)
})
});
};

0 comments on commit 27c9efb

Please sign in to comment.