]> git.proxmox.com Git - extjs.git/blob - extjs/packages/core/test/specs/dom/Element_scroll.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / test / specs / dom / Element_scroll.js
1 describe("Ext.dom.Element_scroll", function() {
2
3 var el;
4
5 afterEach(function(){
6 Ext.destroy(el);
7 el = null;
8 });
9
10 function expectLeft(left) {
11 expect(el.dom.scrollLeft).toBe(left);
12 }
13
14 function expectTop(top) {
15 expect(el.dom.scrollTop).toBe(top);
16 }
17
18 function expectLeftTop(left, top) {
19 expectLeft(left);
20 expectTop(top);
21 }
22
23 describe("scroll", function() {
24 var scrollSize = Ext.getScrollbarSize(),
25 maxHorz = 600 + scrollSize.width,
26 maxVert = 600 + scrollSize.height;
27
28 beforeEach(function(){
29 el = Ext.getBody().createChild({
30 style: {
31 width: '400px',
32 height: '400px',
33 overflow: 'auto'
34 },
35 cn: [{
36 style: {
37 width: '1000px',
38 height: '1000px'
39 }
40 }]
41 });
42 });
43
44 describe("right", function(){
45 it("should accept 'right' as a param", function(){
46 el.scroll('right', 200);
47 expectLeft(200);
48 });
49
50 it("should accept 'r' as a param", function(){
51 el.scroll('r', 175);
52 expectLeft(175);
53 });
54
55 it("should append to the current position", function(){
56 el.scroll('r', 200);
57 el.scroll('r', 300);
58 expectLeft(500);
59 });
60
61 it("should constrain the max scroll", function(){
62 el.scroll('r', 2000);
63 expectLeft(maxHorz);
64 });
65 });
66
67 describe("left", function(){
68 it("should accept 'left' as a param", function(){
69 el.scroll('r', 200);
70 el.scroll('left', 125);
71 expectLeft(75);
72 });
73
74 it("should accept 'l' as a param", function(){
75 el.scroll('r', 300);
76 el.scroll('l', 150);
77 expectLeft(150);
78 });
79
80 it("should append to the current position", function(){
81 el.scroll('r', 500);
82 el.scroll('l', 300);
83 el.scroll('l', 100);
84 expectLeft(100);
85 });
86
87 it("should constrain to 0", function(){
88 el.scroll('r', 100);
89 el.scroll('l', 350);
90 expectLeft(0);
91 });
92 });
93
94 describe("bottom", function(){
95 it("should accept 'bottom' as a param", function() {
96 el.scroll('bottom', 30);
97 expectTop(30);
98 });
99
100 it("should accept 'b' as a param", function() {
101 el.scroll('b', 120);
102 expectTop(120);
103 });
104
105 it("should accept 'down' as a param", function() {
106 el.scroll('down', 30);
107 expectTop(30);
108 });
109
110 it("should accept 'd' as a param", function() {
111 el.scroll('d', 375);
112 expectTop(375);
113 });
114
115 it("should append to the current position", function() {
116 el.scroll('b', 120);
117 el.scroll('b', 130);
118 expectTop(250);
119 });
120
121 it("should constrain the max scroll", function(){
122 el.scroll('b', 1500);
123 expectTop(maxVert);
124 });
125 });
126
127 describe("up", function(){
128 it("should accept 'up' as a param", function() {
129 el.scroll('b', 30);
130 el.scroll('u', 10);
131 expectTop(20);
132 });
133
134 it("should accept 'u' as a param", function() {
135 el.scroll('b', 120);
136 el.scroll('u', 50);
137 expectTop(70);
138 });
139
140 it("should accept 'top' as a param", function() {
141 el.scroll('b', 200);
142 el.scroll('top', 130);
143 expectTop(70);
144 });
145
146 it("should accept 't' as a param", function() {
147 el.scroll('b', 500);
148 el.scroll('t', 375);
149 expectTop(125);
150 });
151
152 it("should append to the current position", function() {
153 el.scroll('b', 300);
154 el.scroll('t', 120);
155 el.scroll('t', 130);
156 expectTop(50);
157 });
158
159 it("should constrain the max scroll", function() {
160 el.scroll('b', 300);
161 el.scroll('t', 3000);
162 expectTop(0);
163 });
164 });
165
166 });
167
168 });