PDA

View Full Version : Generated getter doesn't return default config



tengl
20 Dec 2011, 4:28 AM
Hi, shouldn't the default values on configs be applied (using the apply function) when a class instance is created? The third test (Jasmine) in the example below failed for me (ExtJS 4.0.7). It works if I set the configureThis when creating the instance.




Ext.define('MyClass', {
config: {
configureThis: 'Default value'
}
});

describe('Class applies default values', function () {
var myClass;
beforeEach(function () {
myClass = Ext.create('MyClass');
});

it('should have a default value', function () {
expect(myClass.config.configureThis).toEqual('Default value');
});

it('should be able to update config', function () {
myClass.setConfigureThis('Other value');
expect(myClass.configureThis).toEqual('Other value');
});

it('should be able to get the config value', function () {
expect(myClass.getConfigureThis()).toEqual('Default value');
});
});

tengl
20 Dec 2011, 4:49 AM
I didn't read the example in the documentation good enough.
Seems like you have to manually initialize the config. Is there a reason for that not being done in the base class?
Maybe the documentation could point out that initConfig must be called (in the text as well)?



constructor: function(config) {
this.initConfig(config);

return this;
}