wardbell / bardjs

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

mockService cannot omit config #26

Open kburson opened 8 years ago

kburson commented 8 years ago

If you try to use mockService without the config you will get an error:

    TypeError: Cannot read property '_default' of undefined
        at node_modules/bardjs/dist/bard.js:560:37

The problem area is here where if the config has a key you use that key, otherwise you use the config._default, but if there is no config there can be no config._default...

  var value = configKeys.indexOf(key) > -1 ?
                config[key] : config._default;
TueCN commented 8 years ago

Yup this is an issue because the doc clearly states that you should be able to omit config:

/**
 * Mocks out a service with sinon stubbed functions
 * that return the values specified in the config
 *
 * If the config value is `undefined`,
 * stub the service method with a dummy that doesn't return a value
johnmcase commented 8 years ago

+1