score:0

Accepted answer

Temporary answer until someone has a better one (one that doesn't involve mocking filter)

Adding a filter function to __proto__ stops the error.

var toFilter =[
    {
        0: [
            {
                id: "textID2#StatusChangeChart",
                textContent: "New",
                __data__: "hi"
            }
        ]
    }
];

var texts = {
    _group: toFilter,
    fontFamily: "shouldChange",
    __proto__:{
        attr: function (name, value) {
            if (name === 'font-family') {
                this.fontFamily = value;
            }
        },
        filter: function (value, index,arr){
            return {_groups:[undefined]};
        }
    }

};

Personally, I'll need to change undefined to actually return things I can change thestyle of for the rest of the function I'm testing so the actual functionality of the function this is in can be tested. But for anyone wondering how to solve the issue in the future just add your own function instead of using the pre-made library functions. You are not testing their functionality. You are testing yours. Make it return what you want it to return and see if your function holds up with the data you expect it to hold up with.


Related Query