It seems to me that you cannot do the right thing cart_proxy
and that the main reason for the failure of the test. In addition, your test may have several problems.
You have a syntax error. Correct below:
var cartModule = (function() {
var cart = [];
var cart_proxy = new Proxy(cart, {
set: function(target, property, value) {
target[property] = value
return true
}
})
return {
toggleItem: function() {
if (value) {
cart_proxy.push(new Item(item_name));
}
},
getItems: function() {
return cart.map( object => object.name );
}
}
})
, new Proxy(
, -, ,
. cart.push
, cart
, , - cart_proxy
.
, beforeEach
:
beforeEach(function() {
cartModule.toggleItem("ladder", true)
})
, toggleItem
- cartModule
, , 2 .
.