-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMDLDisplayPaginatedTableContentTest.class.st
More file actions
256 lines (195 loc) · 8.59 KB
/
MDLDisplayPaginatedTableContentTest.class.st
File metadata and controls
256 lines (195 loc) · 8.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
"
A MDLDisplayPaginatedTableContentTest is a test class for testing the behavior of MDLDisplayPaginatedTableContent
"
Class {
#name : #MDLDisplayPaginatedTableContentTest,
#superclass : #SGTAbstractSeasideTestCase,
#category : #'Material-Design-Lite-Widgets-Tests-Table'
}
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testIndexOfLastRowToShow [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self assert: contentDisplayStrategy rowsPerPage equals: 5.
self assert: contentDisplayStrategy indexOfLastRowToShow equals: 5.
contentDisplayStrategy rowsPerPage: 10.
self assert: contentDisplayStrategy rowsPerPage equals: 10.
self assert: contentDisplayStrategy indexOfLastRowToShow equals: 10.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testInitialize [
| contentDisplayStrategy |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition.
self assert: contentDisplayStrategy rowsPerPagePossibilities equals: contentDisplayStrategy defaultRowsPerPagePossibilities
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testIsAtEnd [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition.
contentDisplayStrategy rowsPerPage: 50.
self deny: contentDisplayStrategy isAtEnd.
self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition.
contentDisplayStrategy nextPosition.
self assert: contentDisplayStrategy isAtEnd.
self assert: contentDisplayStrategy position equals: 51.
"Do not move if we call #nextPosition again."
contentDisplayStrategy nextPosition.
self assert: contentDisplayStrategy isAtEnd.
self assert: contentDisplayStrategy position equals: 51.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testNextPosition [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition.
self assert: contentDisplayStrategy rowsPerPage equals: 5.
contentDisplayStrategy nextPosition.
self assert: contentDisplayStrategy position equals: 6.
contentDisplayStrategy nextPosition.
self assert: contentDisplayStrategy position equals: 11.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testNextPosition2 [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self assert: contentDisplayStrategy position equals: contentDisplayStrategy initialPosition.
contentDisplayStrategy rowsPerPage: 10.
contentDisplayStrategy nextPosition.
self assert: contentDisplayStrategy position equals: 11.
contentDisplayStrategy nextPosition.
self assert: contentDisplayStrategy position equals: 21.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testPreviousPosition [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
contentDisplayStrategy rowsPerPage: 10.
contentDisplayStrategy position: 91.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 81.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 71.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 61.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 51.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 41.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 31.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 21.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 11.
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 1.
"Check it does nothing once we reached beginning of collection."
contentDisplayStrategy previousPosition.
self assert: contentDisplayStrategy position equals: 1.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testRenderPagesInfoOn [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self
assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ]
generates: '1 - 5 of 100'.
contentDisplayStrategy nextPosition.
self
assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ]
generates: '6 - 10 of 100'.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testRenderPagesInfoOn2 [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
contentDisplayStrategy rowsPerPage: 10.
self
assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ]
generates: '1 - 10 of 100'.
contentDisplayStrategy nextPosition.
self
assert: [ :html | contentDisplayStrategy renderPagesInfoOn: html ]
generates: '11 - 20 of 100'.
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testRowsPerPage [
| contentDisplayStrategy |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
self assert: contentDisplayStrategy rowsPerPage equals: contentDisplayStrategy rowsPerPagePossibilities first
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testRowsPerPageRowsPerPagePossibilitiesIsEmpty [
| contentDisplayStrategy |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
contentDisplayStrategy rowsPerPagePossibilities: #().
self
should: [ contentDisplayStrategy rowsPerPage ]
raise: Error
withExceptionDo: [ :ex | self assert: ex messageText equals: '#rowsPerPagePossibilities is empty' ]
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testRowsToDisplayDo [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(1 2 3 4 5).
contentDisplayStrategy nextPosition.
self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(6 7 8 9 10).
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testRowsToDisplayDo2 [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
contentDisplayStrategy rowsPerPage: 10.
self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(1 2 3 4 5 6 7 8 9 10).
contentDisplayStrategy nextPosition.
self assertCollection: (Array streamContents: [ :stream | contentDisplayStrategy rowsToDisplayDo: [ :i | stream nextPut: i ] ]) equals: #(11 12 13 14 15 16 17 18 19 20).
]
{ #category : #test }
MDLDisplayPaginatedTableContentTest >> testTotalNumberOfRows [
| contentDisplayStrategy table |
contentDisplayStrategy := MDLDisplayPaginatedTableContent new.
table := MDLTableWidget new
contentDisplayStrategy: contentDisplayStrategy;
collection: (1 to: 100) asArray;
yourself.
self assert: contentDisplayStrategy totalNumberOfRows equals: table collection size.
]