[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 /** 2 * @requires javelin-view 3 * javelin-util 4 */ 5 6 describe('JX.View', function() { 7 JX.install('TestView', { 8 extend : 'View', 9 construct : function(name, attrs, children) { 10 JX.View.call(this, attrs, children); 11 this.setName(name); 12 }, 13 14 members : { 15 getDefaultAttributeValues : function() { 16 return {id: 'test'}; 17 }, 18 render : function(rendered_children) { 19 return JX.$N( 20 'span', 21 {id : this.getAttr('id')}, 22 [this.getName()].concat(rendered_children) 23 ); 24 } 25 } 26 }); 27 28 it('should by default render children that are passed in', function() { 29 var t = new JX.TestView( 30 '', 31 {}, 32 [new JX.TestView('Hey', {id: "child"}, [])] 33 ); 34 var result = JX.ViewRenderer.render(t); 35 expect(JX.DOM.scry(result, 'span').length).toBe(1); 36 }); 37 38 it('should fail sanely with a bad getAttr call', function() { 39 expect(new JX.TestView('', {}, []).getAttr('foo')).toBeUndefined(); 40 }); 41 42 it('should allow attribute setting with multiset', function() { 43 var test_val = 'something else'; 44 expect(new JX.TestView('', {}, []).multisetAttr({ 45 id: 'some_id', 46 other: test_val 47 }).getAttr('other')).toBe(test_val); 48 }); 49 50 it('should allow attribute setting with setAttr', function() { 51 var test_val = 'something else'; 52 expect(new JX.TestView('', {}, []) 53 .setAttr('other', test_val) 54 .getAttr('other')).toBe(test_val); 55 }); 56 57 it('should set default attributes per getDefaultAttributeValues', function() { 58 // Also the test for getAttr 59 expect(new JX.TestView('', {}, []).getAttr('id')).toBe('test'); 60 }); 61 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |