bardjs icon indicating copy to clipboard operation
bardjs copied to clipboard

mockService cannot omit config

Open kburson opened this issue 9 years ago • 2 comments

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;

kburson avatar Nov 20 '15 19:11 kburson

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

TueCN avatar Jan 14 '16 09:01 TueCN

+1

johnmcase avatar Jan 27 '16 20:01 johnmcase