UNPKG

extjs-gpl

Version:

GPL licensed version of Sencha Ext JS

1,392 lines (1,174 loc) 135 kB
describe("Ext.Class", function() { var emptyFn = function(){}, defaultInitConfig = function(config) { this.initConfig(config); }, cls, sub, fn, subClass, parentClass, mixinClass1, mixinClass2, o; beforeEach(function() { fn = function(){}; mixinClass1 = Ext.define(null, { config: { mixinConfig: 'mixinConfig' }, constructor: function(config) { this.initConfig(config); this.mixinConstructor1Called = true; }, mixinProperty1: 'mixinProperty1', mixinMethod1: function() { this.mixinMethodCalled = true; } }); mixinClass2 = Ext.define(null, { constructor: function(config) { this.initConfig(config); this.mixinConstructor2Called = true; }, mixinProperty2: 'mixinProperty2', mixinMethod2: function() { this.mixinMethodCalled = true; } }); parentClass = Ext.define(null, { mixins: { mixin1: mixinClass1 }, config: { name: 'parentClass', isCool: false, members: { abe: 'Abraham Elias', ed: 'Ed Spencer' }, hobbies: ['football', 'bowling'] }, constructor: function(config) { this.initConfig(config); this.parentConstructorCalled = true; this.mixins.mixin1.constructor.apply(this, arguments); }, parentProperty: 'parentProperty', parentMethod: function() { this.parentMethodCalled = true; } }); subClass = Ext.define(null, { extend: parentClass, mixins: { mixin1: mixinClass1, mixin2: mixinClass2 }, config: { name: 'subClass', isCool: true, members: { jacky: 'Jacky Nguyen', tommy: 'Tommy Maintz' }, hobbies: ['sleeping', 'eating', 'movies'], isSpecial: true }, constructor: function(config) { this.initConfig(config); this.subConstructorCalled = true; subClass.superclass.constructor.apply(this, arguments); this.mixins.mixin2.constructor.apply(this, arguments); }, myOwnMethod: function() { this.myOwnMethodCalled = true; } }); }); afterEach(function() { o = subClass = parentClass = mixinClass1 = mixinClass2 = sub = cls = null; }); describe("extend", function() { beforeEach(function() { fn = function() {}; Ext.define('spec.Base', { aProp: 1, aFn: fn }); }); afterEach(function() { Ext.undefine('spec.Base'); }); it("should extend from Base if no 'extend' property found", function() { cls = Ext.define(null, {}); expect((new cls()) instanceof Ext.Base).toBe(true); }); describe("extending from a parent", function() { it("class reference", function() { cls = Ext.define(null, { extend: spec.Base }); expect((new cls()) instanceof spec.Base).toBe(true); }); it("class string", function() { cls = Ext.define(null, { extend: 'spec.Base' }); expect((new cls()) instanceof spec.Base).toBe(true); }); }); it("should have superclass reference", function() { var parentPrototype = spec.Base.prototype; cls = Ext.define(null, { extend: spec.Base }); expect(cls.superclass).toBe(parentPrototype); expect((new cls()).superclass).toBe(parentPrototype); }); it("should copy properties from the parent", function() { cls = Ext.define(null, { extend: spec.Base }); expect(cls.prototype.aProp).toBe(1); }); it("should copy functions from the parent", function() { cls = Ext.define(null, { extend: spec.Base }); expect(cls.prototype.aFn).toBe(fn); }); }); describe("config", function() { beforeEach(function() { fn = function() {}; }); describe("getter/setter creation", function() { it("should create getter if not exists", function() { cls = Ext.define(null, { config: { someName: 'someValue' } }); expect(cls.prototype.getSomeName).toBeDefined(); }); it("should NOT create getter if already exists", function() { var cls = Ext.define(null, { getSomeName: fn, config: { someName: 'someValue' } }); expect(cls.prototype.getSomeName).toBe(fn); }); it("should create setter if not exists", function() { cls = Ext.define(null, { config: { someName: 'someValue' } }); expect(cls.prototype.setSomeName).toBeDefined(); }); it("should NOT create setter if already exists", function() { cls = Ext.define(null, { setSomeName: fn, config: { someName: 'someValue' } }); expect(cls.prototype.setSomeName).toBe(fn); }); it("should allow a custom getter to call the generated getter", function() { cls = Ext.define(null, { config: { someName: 'foo' }, constructor: defaultInitConfig, getSomeName: function() { return this.callParent().toUpperCase(); } }); o = new cls(); expect(o.getSomeName()).toBe('FOO'); }); it("should allow a custom setter to call the generated setter", function() { cls = Ext.define(null, { config: { someName: 'foo' }, constructor: defaultInitConfig, setSomeName: function(someName) { someName = someName.toUpperCase(); return this.callParent([someName]); } }); o = new cls(); expect(o.getSomeName()).toBe('FOO'); }); it("should not set the value if the applier returns undefined", function() { var called = false; cls = Ext.define(null, { config: { foo: 1 }, constructor: defaultInitConfig, applyFoo: function(foo) { if (!called) { called = true; return foo; } return undefined; } }); o = new cls(); o.setFoo(2); expect(o.getFoo()).toBe(1); }); it("should not call the updater if the value does not change", function() { var count = 0; cls = Ext.define(null, { config: { foo: 1 }, constructor: defaultInitConfig, updateFoo: function() { ++count; } }); o = new cls(); o.setFoo(1); expect(count).toBe(1); }); it("should check using === to see if the value changed", function() { var count = 0; cls = Ext.define(null, { config: { foo: 1 }, constructor: defaultInitConfig, updateFoo: function() { ++count; } }); o = new cls(); o.setFoo('1'); expect(count).toBe(2); }); it("should allow defining a config named 'configurator'", function () { cls = Ext.define(null, { config: { configurator: 1 }, constructor: defaultInitConfig, applyConfigurator: function(v) { return v+1; } }); o = new cls(); expect(o.getConfigurator()).toBe(2); o.setConfigurator(5); expect(o.getConfigurator()).toBe(6); }); describe("when getters are called by other configs' updaters", function() { var applyCount, updateCount; beforeEach(function() { cls = Ext.define(null, { config: { foo: 1, bar: 2 }, constructor: defaultInitConfig, updateFoo: function() { // this assumes that the configs are processed in the order // they were defined. Since we process them using a for/in // loop, we can be reasonably certain foo gets processed // before bar. Call the getter here means we call it before // the config system does. This test ensures the config // system does not call getBar() a second time. this.getBar(); }, applyBar: function(bar) { ++applyCount; return bar; }, updateBar: function() { ++updateCount; } }); }); it("should only call appliers/updaters once for class configs", function() { applyCount = updateCount = 0; o = new cls(); expect(applyCount).toBe(1); expect(updateCount).toBe(1); }); it("should only call appliers/updaters once for instance configs", function() { applyCount = updateCount = 0; o = new cls({ foo: 10, bar: 20 }); expect(applyCount).toBe(1); expect(updateCount).toBe(1); }); }); describe("initialization", function() { describe("default values - no passed config", function() { describe("null", function() { it("should not initialize the config", function() { cls = Ext.define(null, { config: { foo: null }, constructor: function(config) { spyOn(this, 'setFoo'); this.initConfig(config); } }); o = new cls(); expect(o.setFoo).not.toHaveBeenCalled(); }); it("should not initialize with a custom setter", function() { var called = false; cls = Ext.define(null, { config: { foo: null }, constructor: defaultInitConfig, setFoo: function() { called = true; } }); o = new cls(); expect(called).toBe(false); }); it("should not initialize with an applier", function() { var called = false; cls = Ext.define(null, { config: { foo: null }, constructor: defaultInitConfig, applyFoo: function() { called = true; } }); o = new cls(); expect(called).toBe(false); }); it("should not initialize with an updater", function() { var called = false; cls = Ext.define(null, { config: { foo: null }, constructor: defaultInitConfig, updateFoo: function() { called = true; } }); o = new cls(); expect(called).toBe(false); }); }); describe("other values", function() { it("should not call the setter", function() { cls = Ext.define(null, { config: { foo: 1 }, constructor: function(config) { spyOn(this, 'setFoo'); this.initConfig(config); } }); o = new cls(); expect(o.setFoo).not.toHaveBeenCalled(); }); it("should call the setter if there is a custom setter", function() { cls = Ext.define(null, { config: { foo: 1 }, constructor: function(config) { spyOn(this, 'setFoo'); this.initConfig(config); }, setFoo: function() { } }); o = new cls(); expect(o.setFoo).toHaveBeenCalled(); }); it("should call the setter if there is an applier", function() { cls = Ext.define(null, { config: { foo: 1 }, constructor: function(config) { spyOn(this, 'setFoo'); this.initConfig(config); }, applyFoo: function(foo) { return foo; } }); o = new cls(); expect(o.setFoo).toHaveBeenCalled(); }); it("should call the setter if there is an updater", function() { cls = Ext.define(null, { config: { foo: 1 }, constructor: function(config) { spyOn(this, 'setFoo'); this.initConfig(config); }, setFoo: function() { } }); o = new cls(); expect(o.setFoo).toHaveBeenCalled(); }); it("should call the setter if the value is an object", function() { cls = Ext.define(null, { config: { foo: {} }, constructor: function(config) { spyOn(this, 'setFoo'); this.initConfig(config); } }); o = new cls(); expect(o.setFoo).toHaveBeenCalled(); }); }); }); describe("dependencies", function() { it("should force an initialization if the getter is called during init time for a primitive", function() { var secondVal; cls = Ext.define(null, { config: { first: undefined, second: undefined }, constructor: defaultInitConfig, updateFirst: function() { secondVal = this.getSecond(); } }); new cls({ first: 1, second: 2 }); expect(secondVal).toBe(2); }); it("should have a non-config applied by the time any setter is called with non-strict mode", function() { var secondVal; cls = Ext.define(null, { config: { first: undefined }, constructor: defaultInitConfig, $configStrict: false, applyFirst: function() { secondVal = this.second; } }); new cls({ first: 1, second: 2 }); expect(secondVal).toBe(2); }); }); }); }); describe("get/setConfig", function() { beforeEach(function() { cls = Ext.define(null, { config: { foo: 1, bar: 2 }, constructor: defaultInitConfig }); }); describe('dependency ordering', function () { var order; function declareClass () { order = []; cls = Ext.define(null, { config: { b: 'bbb', c: 'ccc', a: 'aaa' }, constructor: defaultInitConfig, applyA: function (value) { order.push('a=' + value); }, applyB: function (value) { this.getA(); order.push('b=' + value); }, applyC: function (value) { this.getB(); order.push('c=' + value); } }); } it('should initialize dependent config first', function () { declareClass(); var o = new cls(); expect(order).toEqual(['a=aaa', 'b=bbb', 'c=ccc']); }); it('should update configs in dependency order', function () { declareClass(); var o = new cls(); order.length = 0; // Because the objects tend to be enumerated in order of keys // declared, we deliberately put these *not* in the order that // we expect them to be processed. At least in Chrome 33 this // test would fail w/o a fix to setConfig that checks if the // initGetter is still in place and avoid calling setB() twice! // Of course, putting the keys in a,b,c order would pass! o.setConfig({ a: 1, c: 3, // IMPORTANT - not in dependency order! b: 2 }); expect(order).toEqual(['a=1', 'b=2', 'c=3']); }); }); describe("getConfig", function() { it("should be able to get a config by name", function() { o = new cls(); expect(o.getConfig('bar')).toBe(2); }); it("should return all configs if no name is passed", function() { o = new cls(); expect(o.getConfig()).toEqual({ foo: 1, bar: 2 }); }); it("should throw an exception when asking for a config name that does not exist", function() { spyOn(Ext, 'log'); o = new cls(); expect(function() { o.getConfig('fake'); }).toThrow(); }); describe("peek", function() { beforeEach(function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: { lazy: true, $value: 120 } } }); }); it("should not call the getter if the initGetter has not yet been called", function() { o = new cls({ foo: 1 }); spyOn(o, 'getFoo'); o.getConfig('foo', true); expect(o.getFoo).not.toHaveBeenCalled(); }); it("should return the pending value configured on the instance", function() { o = new cls({ foo: 1 }); expect(o.getConfig('foo', true)).toBe(1); }); it("should return the pending value configured on the class", function() { o = new cls(); expect(o.getConfig('foo', true)).toBe(120); }); }); }); describe("setConfig", function() { it("should be able to set a config by name", function() { o = new cls(); o.setConfig('foo', 7); expect(o.getFoo()).toBe(7); }); it("should be able to set a group of configs at once", function() { o = new cls(); o.setConfig({ foo: 6, bar: 8 }); expect(o.getFoo()).toBe(6); expect(o.getBar()).toBe(8); }); it("should call the setter for a non-config property if one exists and $configStrict is false", function() { cls = Ext.define(null, { $configStrict: false, constructor: defaultInitConfig, setBaz: jasmine.createSpy() }); o = new cls(); o.setConfig({ baz: 100 }); expect(o.setBaz).toHaveBeenCalledWith(100); }); it("should set non-config properties on the instance when the strict option is false and $configStrict is false", function() { cls = Ext.define(null, { $configStrict: false, constructor: defaultInitConfig }); o = new cls(); o.setConfig('baz', 100, { strict: false }); expect(o.baz).toBe(100); }); it("should be able to handle undefined/null configs", function() { o = new cls(); expect(function() { o.setConfig(null); o.setConfig(undefined); }).not.toThrow(); }); it("should return the current instance", function() { o = new cls(); expect(o.setConfig()).toBe(o); }); }); }); it("should merge properly", function() { var obj = new subClass; expect(obj.config).toEqual({ mixinConfig: 'mixinConfig', name: 'subClass', isCool: true, members: { abe: 'Abraham Elias', ed: 'Ed Spencer', jacky: 'Jacky Nguyen', tommy: 'Tommy Maintz' }, hobbies: ['sleeping', 'eating', 'movies'], isSpecial: true }); }); it("should apply default config", function() { var obj = new subClass; expect(obj.getName()).toBe('subClass'); expect(obj.getIsCool()).toBe(true); expect(obj.getHobbies()).toEqual(['sleeping', 'eating', 'movies']); }); it("should apply with supplied config", function() { var obj = new subClass({ name: 'newName', isCool: false, members: { aaron: 'Aaron Conran' } }); expect(obj.getName()).toBe('newName'); expect(obj.getIsCool()).toBe(false); expect(obj.getMembers().aaron).toBe('Aaron Conran'); }); it("should not share the same config", function() { var obj1 = new subClass({ name: 'newName', isCool: false, members: { aaron: 'Aaron Conran' } }); var obj2 = new subClass(); expect(obj2.getName()).not.toBe('newName'); }); it("should copy objects", function() { var o1 = new parentClass(), o2 = new parentClass(), m1 = o1.getMembers(), m2 = o2.getMembers(); expect(m1).not.toBe(m2); expect(m1).toEqual(m2); }); it("should not clone dom nodes in an object", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: null } }); var el = document.createElement('div'); var o = new cls({ foo: { bar: el } }); expect(o.getFoo().bar).toBe(el); }); // Possibly need to revisit this, arrays are not cloned. it("should copy arrays", function() { var o1 = new parentClass(), o2 = new parentClass(), h1 = o1.getHobbies(), h2 = o2.getHobbies(); expect(h1).not.toBe(h2); expect(h1).toEqual(h2); }); describe("values", function() { it("should set the the config value defined", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); expect((new cls()).getFoo()).toBe('bar'); }); it("should be able to set the config", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); o = new cls(); o.setFoo('baz'); expect(o.getFoo()).toBe('baz'); o = null; }); it("should use the inherited config", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); sub = Ext.define(null, { extend: cls, config: { foo: 'baz' } }); expect((new sub()).getFoo()).toBe('baz'); }); it("should inherit the parent value even if not specified in the config block", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); sub = Ext.define(null, { extend: cls, config: { herp: 'derp' } }); expect((new sub()).getFoo()).toBe('bar'); }); }); describe("value on prototype", function() { it("should read the value from the prototype in a subclass", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); sub = Ext.define(null, { extend: cls, foo: 'baz' }); expect((new sub()).getFoo()).toBe('baz'); }); it("should remove the property from the prototype", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); sub = Ext.define(null, { extend: cls, foo: 'baz' }); expect(sub.prototype.foo).toBeUndefined(); }); it("should favour the property on the config", function() { cls = Ext.define(null, { constructor: defaultInitConfig, foo: 'baz', config: { foo: 'bar' } }); expect((new cls()).getFoo()).toBe('bar'); }); it("should favour the property on the prototype in a subclass", function() { cls = Ext.define(null, { constructor: defaultInitConfig, config: { foo: 'bar' } }); sub = Ext.define(null, { extend: cls, foo: 'baz' }); expect((new sub()).getFoo()).toBe('baz'); }); it("should pull the property from the prototype in the subclass if it exists on the parent prototype", function() { cls = Ext.define(null, { constructor: defaultInitConfig, foo: 'baz', config: { foo: 'bar' } }); sub = Ext.define(null, { extend: cls, foo: 'bleh' }); expect((new sub()).getFoo()).toBe('bleh'); }); }); describe("$configStrict", function() { describe("initial config", function() { it("should copy non-configs to the instance when true", function() { cls = Ext.define(null, { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); it("should not copy non-configs to the instance when true if the class has a non-$nullFn method by the same name", function() { Ext.define('spec.MyClass', { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: function () {} }); expect(function() { o = new spec.MyClass({ baz: 1 }); }).toThrow('Cannot override method baz on spec.MyClass instance.'); Ext.undefine('spec.MyClass'); }); it("should copy non-configs to the instance when false if the class has a non-$nullFn method by the same name", function() { cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: function () {} }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); it("should copy non-configs to the instance when false", function() { cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); it("should not copy if the subclass sets the property to true", function() { cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig }); sub = Ext.define(null, { extend: sub, $configStrict: true }); o = new sub({ baz: 1 }); expect(o.baz).not.toBeDefined(); }); it('should copy non-configs to the instance when true if the class has a emptyFn by the same name', function() { cls = Ext.define(null, { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.emptyFn }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); it('should copy non-configs to the instance when true if the class has a identityFn by the same name', function() { cls = Ext.define(null, { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.identityFn }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); it('should copy non-configs to the instance when false if the class has a emptyFn by the same name', function() { cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.emptyFn }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); it('should copy non-configs to the instance when false if the class has a identityFn by the same name', function() { cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.identityFn }); o = new cls({ baz: 1 }); expect(o.baz).toBe(1); }); }); describe("reconfigure", function() { it("should copy non-configs to the instance with warning when true", function() { spyOn(Ext.log, 'warn'); Ext.define('spec.MyClass', { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig }); o = new spec.MyClass(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).toHaveBeenCalledWith('No such config "baz" for class spec.MyClass'); Ext.undefine('spec.MyClass'); }); it("should copy non-configs to the instance without warning when false", function() { spyOn(Ext.log, 'warn'); cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig }); o = new cls(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).not.toHaveBeenCalled(); }); it("should not copy non-configs to the instance when true if the class has a non-$nullFn method by the same name", function() { Ext.define('spec.MyClass', { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: function () {} }); o = new spec.MyClass(); expect(function() { o.setConfig({ baz: 1 }); }).toThrow('Cannot override method baz on spec.MyClass instance.'); Ext.undefine('spec.MyClass'); }); it("should copy non-configs to the instance without warning when false if the class has a non-$nullFn method by the same name", function() { spyOn(Ext.log, 'warn'); cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: function () {} }); o = new cls(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).not.toHaveBeenCalled(); }); it('should copy non-configs to the instance with warning when true if the class has a emptyFn by the same name', function() { spyOn(Ext.log, 'warn'); Ext.define('spec.MyClass', { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.emptyFn }); o = new spec.MyClass(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).toHaveBeenCalledWith('No such config "baz" for class spec.MyClass'); Ext.undefine('spec.MyClass'); }); it('should copy non-configs to the instance with warning when true if the class has a identityFn by the same name', function() { spyOn(Ext.log, 'warn'); Ext.define('spec.MyClass', { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.identityFn }); o = new spec.MyClass(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).toHaveBeenCalledWith('No such config "baz" for class spec.MyClass'); Ext.undefine('spec.MyClass'); }); it('should copy non-configs to the instance without warning when false if the class has a emptyFn by the same name', function() { spyOn(Ext.log, 'warn'); cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.emptyFn }); o = new cls(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).not.toHaveBeenCalled(); }); it('should copy non-configs to the instance without warning when false if the class has a identityFn by the same name', function() { spyOn(Ext.log, 'warn'); cls = Ext.define(null, { $configStrict: false, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.identityFn }); o = new cls(); o.setConfig({ baz: 1 }); expect(o.baz).toBe(1); expect(Ext.log.warn).not.toHaveBeenCalled(); }); it('should copy a "type" property without warning when true', function() { spyOn(Ext.log, 'warn'); cls = Ext.define(null, { $configStrict: true, config: { foo: 'bar' }, constructor: defaultInitConfig, baz: Ext.emptyFn }); o = new cls(); o.setConfig({ type: 1 }); expect(o.type).toBe(1); expect(Ext.log.warn).not.toHaveBeenCalled(); }); }); }); describe("$configPrefixed", function() { var defineCls = function(prefix, defaultValue) { cls = Ext.define(null, { $configPrefixed: !!prefix, config: { foo: defaultValue || 'bar' }, constructor: defaultInitConfig }); }; it("should use the config name as the instance property when false", function() { defineCls(); o = new cls(); expect(o.foo).toBe('bar'); }); it("should use _config name as the instance property when true", function() { defineCls(true); o = new cls(); expect(o._foo).toBe('bar'); }); it("should allow a subclass to have a different prefix", function() { defineCls(false, {}); sub = Ext.define(null, { extend: cls, $configPrefixed: true }); var o1 = new cls(), o2 = new sub(); // Use objects since they won't get stamped on the prototype. expect(o1.foo).toEqual({}); expect(o2._foo).toEqual({}); expect(o2.foo).not.toBeDefined(); }); }); describe("meta configs", function() { describe('mixins', function () { it("should inherit meta configs from mixins", function() { var calls = 0; var Mix = Ext.define(null, { config: { foo: { lazy: true, $value: 42 } } }); var Cls = Ext.define(null, { mixins: { mix: Mix },