1
YUI.add('dom-size-test', function(Y) {
3
ArrayAssert = Y.ArrayAssert;
5
Y.Test.Runner.add(new Y.Test.Case({
6
name: 'Y.DOM._setSize',
8
'should set the node offsetWidth to the given value': function() {
9
var node = document.createElement('div');
11
document.body.appendChild(node);
12
Y.DOM._setSize(node, 'width', 100);
14
Assert.areEqual(100, node.offsetWidth);
15
document.body.removeChild(node);
18
'should set the node offsetHeight to the given value': function() {
19
var node = document.createElement('div');
21
document.body.appendChild(node);
22
Y.DOM._setSize(node, 'height', 100);
24
Assert.areEqual(100, node.offsetHeight);
25
document.body.removeChild(node);
28
'should set the node offsetWidth to zero if given a negative number': function() {
29
var node = document.createElement('div');
31
document.body.appendChild(node);
32
Y.DOM._setSize(node, 'width', -100);
34
Assert.areEqual(0, node.offsetWidth);
35
document.body.removeChild(node);
38
'should set the node offsetHeight to zero if given a negative number': function() {
39
var node = document.createElement('div');
41
document.body.appendChild(node);
42
Y.DOM._setSize(node, 'height', -100);
44
Assert.areEqual(0, node.offsetHeight);
45
document.body.removeChild(node);
48
'should set the offsetWidth via setWidth': function() {
49
var node = document.createElement('div');
51
document.body.appendChild(node);
52
Y.DOM.setWidth(node, 100);
54
Assert.areEqual(100, node.offsetWidth);
55
document.body.removeChild(node);
58
'should set the offsetHeight via setHeight': function() {
59
var node = document.createElement('div');
61
document.body.appendChild(node);
62
Y.DOM.setHeight(node, 100);
64
Assert.areEqual(100, node.offsetHeight);
65
document.body.removeChild(node);
68
'should set offsetWidth accounting for padding': function() {
69
var node = document.createElement('div');
71
document.body.appendChild(node);
72
node.style.padding = '10px';
73
Y.DOM.setWidth(node, 100);
75
Assert.areEqual(100, node.offsetWidth);
76
document.body.removeChild(node);
80
'should set offsetHeight accounting for padding': function() {
81
var node = document.createElement('div');
83
document.body.appendChild(node);
84
node.style.padding = '10px';
85
Y.DOM.setHeight(node, 100);
87
Assert.areEqual(100, node.offsetHeight);
88
document.body.removeChild(node);
91
'should set offsetWidth to padding when setting to zero': function() {
92
var node = document.createElement('div');
94
document.body.appendChild(node);
95
node.style.padding = '10px';
96
Y.DOM.setWidth(node, 0);
98
Assert.areEqual(20, node.offsetWidth);
99
document.body.removeChild(node);
102
'should set offsetHeight to padding when setting to zero': function() {
103
var node = document.createElement('div');
105
document.body.appendChild(node);
106
node.style.padding = '10px';
107
Y.DOM.setHeight(node, 0);
109
Assert.areEqual(20, node.offsetHeight);
110
document.body.removeChild(node);
114
}, '@VERSION@' ,{requires:['dom-base', 'test']});