wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

Correcting the handling of services that have inherited properties #4

Closed vcabbage closed 9 years ago

vcabbage commented 9 years ago

Object.keys returns only an object's own properties. I ran into an issue where a service was using inheritance internally and the mockService function would not overwrite the inherited properties with _default. Explicitly specifying the inherited property worked but _default did not.

Using the 'for (var key in object)' syntax traverses the prototype chain and allows mockService to overwrite inherited properties not explicitly called out in the config with _default.

wardbell commented 9 years ago

Incorporated in release 0.1.2