[76] | 1 | /*! |
---|
| 2 | * Ext JS Library 3.4.0 |
---|
| 3 | * Copyright(c) 2006-2011 Sencha Inc. |
---|
| 4 | * licensing@sencha.com |
---|
| 5 | * http://www.sencha.com/license |
---|
| 6 | */ |
---|
| 7 | /** |
---|
| 8 | * Tests Ext.data.Store functionality |
---|
| 9 | * @author Ed Spencer |
---|
| 10 | */ |
---|
| 11 | (function() { |
---|
| 12 | var suite = Ext.test.session.getSuite('Ext.layout.ContainerLayout'), |
---|
| 13 | assert = Y.Assert; |
---|
| 14 | |
---|
| 15 | function buildLayout(config) { |
---|
| 16 | var layout = new Ext.layout.FormLayout(config || {}); |
---|
| 17 | |
---|
| 18 | //give a mock container |
---|
| 19 | layout.container = { |
---|
| 20 | itemCls: 'ctCls' |
---|
| 21 | }; |
---|
| 22 | |
---|
| 23 | return layout; |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | suite.add(new Y.Test.Case({ |
---|
| 27 | name: 'parseMargins', |
---|
| 28 | |
---|
| 29 | setUp: function() { |
---|
| 30 | this.cont = new Ext.layout.ContainerLayout(); |
---|
| 31 | }, |
---|
| 32 | |
---|
| 33 | testParseFromNumber: function() { |
---|
| 34 | var res = this.cont.parseMargins(10); |
---|
| 35 | |
---|
| 36 | assert.areEqual(10, res.top); |
---|
| 37 | assert.areEqual(10, res.right); |
---|
| 38 | assert.areEqual(10, res.bottom); |
---|
| 39 | assert.areEqual(10, res.left); |
---|
| 40 | }, |
---|
| 41 | |
---|
| 42 | testParseFromString: function() { |
---|
| 43 | var res = this.cont.parseMargins("10"); |
---|
| 44 | |
---|
| 45 | assert.areEqual(10, res.top); |
---|
| 46 | assert.areEqual(10, res.right); |
---|
| 47 | assert.areEqual(10, res.bottom); |
---|
| 48 | assert.areEqual(10, res.left); |
---|
| 49 | }, |
---|
| 50 | |
---|
| 51 | testParseFromTwoArgString: function() { |
---|
| 52 | var res = this.cont.parseMargins("10 5"); |
---|
| 53 | |
---|
| 54 | assert.areEqual(10, res.top); |
---|
| 55 | assert.areEqual(5, res.right); |
---|
| 56 | assert.areEqual(10, res.bottom); |
---|
| 57 | assert.areEqual(5, res.left); |
---|
| 58 | }, |
---|
| 59 | |
---|
| 60 | testParseFromThreeArgString: function() { |
---|
| 61 | var res = this.cont.parseMargins("10 5 2"); |
---|
| 62 | |
---|
| 63 | assert.areEqual(10, res.top); |
---|
| 64 | assert.areEqual(5, res.right); |
---|
| 65 | assert.areEqual(2, res.bottom); |
---|
| 66 | assert.areEqual(5, res.left); |
---|
| 67 | }, |
---|
| 68 | |
---|
| 69 | testParseFromFourArgString: function() { |
---|
| 70 | var res = this.cont.parseMargins("10 5 2 1"); |
---|
| 71 | |
---|
| 72 | assert.areEqual(10, res.top); |
---|
| 73 | assert.areEqual(5, res.right); |
---|
| 74 | assert.areEqual(2, res.bottom); |
---|
| 75 | assert.areEqual(1, res.left); |
---|
| 76 | } |
---|
| 77 | })); |
---|
| 78 | |
---|
| 79 | suite.add(new Y.Test.Case({ |
---|
| 80 | name: 'configureItem', |
---|
| 81 | |
---|
| 82 | setUp: function() { |
---|
| 83 | this.layout = new Ext.layout.ContainerLayout({ |
---|
| 84 | extraCls: 'myExtraClass' |
---|
| 85 | }); |
---|
| 86 | |
---|
| 87 | //mock component object |
---|
| 88 | this.component = { |
---|
| 89 | addClass: Ext.emptyFn, |
---|
| 90 | doLayout: Ext.emptyFn |
---|
| 91 | }; |
---|
| 92 | }, |
---|
| 93 | |
---|
| 94 | testAddsExtraCls: function() { |
---|
| 95 | var layout = this.layout; |
---|
| 96 | |
---|
| 97 | var addedClass = ""; |
---|
| 98 | |
---|
| 99 | //mock component object |
---|
| 100 | c = { |
---|
| 101 | addClass: function(cls) { |
---|
| 102 | addedClass = cls; |
---|
| 103 | } |
---|
| 104 | }; |
---|
| 105 | |
---|
| 106 | layout.configureItem(c, 0); |
---|
| 107 | |
---|
| 108 | assert.areEqual('myExtraClass', addedClass); |
---|
| 109 | }, |
---|
| 110 | |
---|
| 111 | testAddsExtraClsToPositionEl: function() { |
---|
| 112 | var layout = this.layout; |
---|
| 113 | |
---|
| 114 | var addedClass = ""; |
---|
| 115 | |
---|
| 116 | //mock component object |
---|
| 117 | c = { |
---|
| 118 | getPositionEl: function() { |
---|
| 119 | return posEl; |
---|
| 120 | } |
---|
| 121 | }; |
---|
| 122 | |
---|
| 123 | //mock position el |
---|
| 124 | posEl = { |
---|
| 125 | addClass: function(cls) { |
---|
| 126 | addedClass = cls; |
---|
| 127 | } |
---|
| 128 | }; |
---|
| 129 | |
---|
| 130 | layout.configureItem(c, 0); |
---|
| 131 | |
---|
| 132 | assert.areEqual('myExtraClass', addedClass); |
---|
| 133 | }, |
---|
| 134 | |
---|
| 135 | testLaysOutIfForced: function() { |
---|
| 136 | var laidOut = false; |
---|
| 137 | |
---|
| 138 | var layout = this.layout, |
---|
| 139 | comp = this.component; |
---|
| 140 | |
---|
| 141 | //mock component object |
---|
| 142 | comp.doLayout = function() { |
---|
| 143 | laidOut = true; |
---|
| 144 | }; |
---|
| 145 | |
---|
| 146 | layout.configureItem(comp, 0); |
---|
| 147 | |
---|
| 148 | assert.isFalse(laidOut); |
---|
| 149 | |
---|
| 150 | layout.forceLayout = true; |
---|
| 151 | layout.configureItem(comp, 0); |
---|
| 152 | |
---|
| 153 | assert.isTrue(laidOut); |
---|
| 154 | }, |
---|
| 155 | |
---|
| 156 | testHidesIfRenderHidden: function() { |
---|
| 157 | |
---|
| 158 | } |
---|
| 159 | })); |
---|
| 160 | })(); |
---|