@@ -30,7 +30,7 @@ func TestNew(t *testing.T) {
30
30
assert .NotNil (t , sut )
31
31
assert .Equal (t , "*maroto.Maroto" , fmt .Sprintf ("%T" , sut ))
32
32
})
33
- t .Run ("new with config" , func (t * testing.T ) {
33
+ t .Run ("when config is sent, it should create Maroto object " , func (t * testing.T ) {
34
34
// Arrange
35
35
cfg := config .NewBuilder ().
36
36
Build ()
@@ -42,7 +42,7 @@ func TestNew(t *testing.T) {
42
42
assert .NotNil (t , sut )
43
43
assert .Equal (t , "*maroto.Maroto" , fmt .Sprintf ("%T" , sut ))
44
44
})
45
- t .Run ("new with config an concurrent mode on " , func (t * testing.T ) {
45
+ t .Run ("when config with an concurrent mode is sent, should create Maroto object " , func (t * testing.T ) {
46
46
// Arrange
47
47
cfg := config .NewBuilder ().
48
48
WithConcurrentMode (7 ).
@@ -55,7 +55,7 @@ func TestNew(t *testing.T) {
55
55
assert .NotNil (t , sut )
56
56
assert .Equal (t , "*maroto.Maroto" , fmt .Sprintf ("%T" , sut ))
57
57
})
58
- t .Run ("new with config an low memory mode on " , func (t * testing.T ) {
58
+ t .Run ("when config with an low memory mode is sent, should create Maroto object " , func (t * testing.T ) {
59
59
// Arrange
60
60
cfg := config .NewBuilder ().
61
61
WithSequentialLowMemoryMode (10 ).
@@ -71,26 +71,32 @@ func TestNew(t *testing.T) {
71
71
}
72
72
73
73
func TestMaroto_AddRow (t * testing.T ) {
74
- t .Run ("when col is not sent, should empty col is set" , func (t * testing.T ) {
75
- // Arrange
76
- sut := maroto .New ()
74
+ t .Run ("When row height and available sapacing are equals, should add row in current page" , func (t * testing.T ) {
75
+ cfg := config .NewBuilder ().
76
+ WithDimensions (20 , 20 ).
77
+ WithBottomMargin (0 ).
78
+ WithTopMargin (0 ).
79
+ WithLeftMargin (0 ).
80
+ WithRightMargin (0 ).
81
+ Build ()
82
+ sut := maroto .New (cfg )
77
83
// Act
78
- sut .AddRow (10 )
84
+ sut .AddRow (19 )
85
+ sut .AddRow (1 )
79
86
80
87
// Assert
81
- test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_row_4 .json" )
88
+ test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_row .json" )
82
89
})
83
- t .Run ("add one row " , func (t * testing.T ) {
90
+ t .Run ("when col is not sent, should empty col is set " , func (t * testing.T ) {
84
91
// Arrange
85
92
sut := maroto .New ()
86
-
87
93
// Act
88
- sut .AddRow (10 , col . New ( 12 ) )
94
+ sut .AddRow (10 )
89
95
90
96
// Assert
91
- test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_row_1 .json" )
97
+ test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_row_4 .json" )
92
98
})
93
- t .Run ("add one row" , func (t * testing.T ) {
99
+ t .Run ("when one row is sent, should create one row" , func (t * testing.T ) {
94
100
// Arrange
95
101
sut := maroto .New ()
96
102
@@ -100,7 +106,7 @@ func TestMaroto_AddRow(t *testing.T) {
100
106
// Assert
101
107
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_row_1.json" )
102
108
})
103
- t .Run ("add two rows" , func (t * testing.T ) {
109
+ t .Run ("when two rows are sent, should create two rows" , func (t * testing.T ) {
104
110
// Arrange
105
111
sut := maroto .New ()
106
112
@@ -111,7 +117,7 @@ func TestMaroto_AddRow(t *testing.T) {
111
117
// Assert
112
118
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_row_2.json" )
113
119
})
114
- t .Run ("add rows until add new page" , func (t * testing.T ) {
120
+ t .Run ("when rows do not fit on the current page, should create a new page" , func (t * testing.T ) {
115
121
// Arrange
116
122
sut := maroto .New ()
117
123
@@ -136,7 +142,7 @@ func TestMaroto_AddRows(t *testing.T) {
136
142
// Assert
137
143
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_rows_4.json" )
138
144
})
139
- t .Run ("add one row" , func (t * testing.T ) {
145
+ t .Run ("when one row is sent, should create one row" , func (t * testing.T ) {
140
146
// Arrange
141
147
sut := maroto .New ()
142
148
@@ -146,7 +152,7 @@ func TestMaroto_AddRows(t *testing.T) {
146
152
// Assert
147
153
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_rows_1.json" )
148
154
})
149
- t .Run ("add two rows" , func (t * testing.T ) {
155
+ t .Run ("when two rows are sent, should create two rows" , func (t * testing.T ) {
150
156
// Arrange
151
157
sut := maroto .New ()
152
158
@@ -157,7 +163,7 @@ func TestMaroto_AddRows(t *testing.T) {
157
163
// Assert
158
164
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_rows_2.json" )
159
165
})
160
- t .Run ("add rows until add new page" , func (t * testing.T ) {
166
+ t .Run ("when rows do not fit on the current page, should create a new page" , func (t * testing.T ) {
161
167
// Arrange
162
168
sut := maroto .New ()
163
169
@@ -200,7 +206,7 @@ func TestMaroto_AddAutoRow(t *testing.T) {
200
206
}
201
207
202
208
func TestMaroto_AddPages (t * testing.T ) {
203
- t .Run ("add one page" , func (t * testing.T ) {
209
+ t .Run ("when a new page is created, should add a page" , func (t * testing.T ) {
204
210
// Arrange
205
211
sut := maroto .New ()
206
212
@@ -214,7 +220,7 @@ func TestMaroto_AddPages(t *testing.T) {
214
220
// Assert
215
221
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_pages_1.json" )
216
222
})
217
- t .Run ("add two pages" , func (t * testing.T ) {
223
+ t .Run ("when two pages are created, should add two pages" , func (t * testing.T ) {
218
224
// Arrange
219
225
sut := maroto .New ()
220
226
@@ -231,7 +237,7 @@ func TestMaroto_AddPages(t *testing.T) {
231
237
// Assert
232
238
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_add_pages_2.json" )
233
239
})
234
- t .Run ("add page greater than one page " , func (t * testing.T ) {
240
+ t .Run ("when the sent page uses two pages, two pages are created " , func (t * testing.T ) {
235
241
// Arrange
236
242
sut := maroto .New ()
237
243
var rows []core.Row
@@ -248,7 +254,7 @@ func TestMaroto_AddPages(t *testing.T) {
248
254
}
249
255
250
256
func TestMaroto_Generate (t * testing.T ) {
251
- t .Run ("add one row" , func (t * testing.T ) {
257
+ t .Run ("when one row is sent, should generate one row" , func (t * testing.T ) {
252
258
// Arrange
253
259
sut := maroto .New ()
254
260
@@ -260,7 +266,7 @@ func TestMaroto_Generate(t *testing.T) {
260
266
assert .Nil (t , err )
261
267
assert .NotNil (t , doc )
262
268
})
263
- t .Run ("add two rows " , func (t * testing.T ) {
269
+ t .Run ("when two row are sent, should generate two row " , func (t * testing.T ) {
264
270
// Arrange
265
271
sut := maroto .New ()
266
272
@@ -273,7 +279,7 @@ func TestMaroto_Generate(t *testing.T) {
273
279
assert .Nil (t , err )
274
280
assert .NotNil (t , doc )
275
281
})
276
- t .Run ("add rows until add new page" , func (t * testing.T ) {
282
+ t .Run ("when rows do not fit on the current page, should generate two pages " , func (t * testing.T ) {
277
283
// Arrange
278
284
sut := maroto .New ()
279
285
@@ -287,7 +293,7 @@ func TestMaroto_Generate(t *testing.T) {
287
293
assert .Nil (t , err )
288
294
assert .NotNil (t , doc )
289
295
})
290
- t .Run ("add rows until add new page, execute in parallel" , func (t * testing.T ) {
296
+ t .Run ("when rows do not fit on the current page and concurrent mode is active, should executed in parallel" , func (t * testing.T ) {
291
297
// Arrange
292
298
cfg := config .NewBuilder ().
293
299
WithConcurrentMode (7 ).
@@ -305,7 +311,7 @@ func TestMaroto_Generate(t *testing.T) {
305
311
assert .Nil (t , err )
306
312
assert .NotNil (t , doc )
307
313
})
308
- t .Run ("add rows until add new page, execute in low memory mode" , func (t * testing.T ) {
314
+ t .Run ("when two pages are sent and low memory mode is active, should executed in low memory mode" , func (t * testing.T ) {
309
315
// Arrange
310
316
cfg := config .NewBuilder ().
311
317
WithSequentialLowMemoryMode (10 ).
@@ -323,7 +329,7 @@ func TestMaroto_Generate(t *testing.T) {
323
329
assert .Nil (t , err )
324
330
assert .NotNil (t , doc )
325
331
})
326
- t .Run ("sequential generation" , func (t * testing.T ) {
332
+ t .Run ("when two pages are sent and sequential generation is active, should executed in sequential generation mode " , func (t * testing.T ) {
327
333
// Arrange
328
334
cfg := config .NewBuilder ().
329
335
WithSequentialMode ().
@@ -339,7 +345,7 @@ func TestMaroto_Generate(t *testing.T) {
339
345
// Assert
340
346
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_sequential.json" )
341
347
})
342
- t .Run ("sequential low memory generation " , func (t * testing.T ) {
348
+ t .Run ("when two pages are sent and sequential low memory is active, should executed in sequential low memory mode " , func (t * testing.T ) {
343
349
// Arrange
344
350
cfg := config .NewBuilder ().
345
351
WithSequentialLowMemoryMode (10 ).
@@ -355,7 +361,7 @@ func TestMaroto_Generate(t *testing.T) {
355
361
// Assert
356
362
test .New (t ).Assert (sut .GetStructure ()).Equals ("maroto_sequential_low_memory.json" )
357
363
})
358
- t .Run ("sequential low memory generation " , func (t * testing.T ) {
364
+ t .Run ("when two pages are sent and concurrent mode is active, should executed in parallel " , func (t * testing.T ) {
359
365
// Arrange
360
366
cfg := config .NewBuilder ().
361
367
WithConcurrentMode (10 ).
@@ -396,7 +402,7 @@ func TestMaroto_Generate(t *testing.T) {
396
402
assert .Nil (t , err3 )
397
403
assert .Equal (t , initialGoroutines , finalGoroutines )
398
404
})
399
- t .Run ("page number" , func (t * testing.T ) {
405
+ t .Run ("when two pages are sent and page number is active, should add page number" , func (t * testing.T ) {
400
406
// Arrange
401
407
cfg := config .NewBuilder ().
402
408
WithPageNumber ().
@@ -415,7 +421,7 @@ func TestMaroto_Generate(t *testing.T) {
415
421
}
416
422
417
423
func TestMaroto_FitlnCurrentPage (t * testing.T ) {
418
- t .Run ("when component is smaller should available size, then false" , func (t * testing.T ) {
424
+ t .Run ("when component is smaller should available size, should return false" , func (t * testing.T ) {
419
425
sut := maroto .New (config .NewBuilder ().
420
426
WithDimensions (210.0 , 297.0 ).
421
427
Build ())
@@ -428,7 +434,7 @@ func TestMaroto_FitlnCurrentPage(t *testing.T) {
428
434
sut .AddPages (page .New ().Add (rows ... ))
429
435
assert .False (t , sut .FitlnCurrentPage (40 ))
430
436
})
431
- t .Run ("when component is larger should the available size, then true" , func (t * testing.T ) {
437
+ t .Run ("when component is larger should the available size, should return true" , func (t * testing.T ) {
432
438
sut := maroto .New (config .NewBuilder ().
433
439
WithDimensions (210.0 , 297.0 ).
434
440
Build ())
@@ -458,7 +464,7 @@ func TestMaroto_FitlnCurrentPage(t *testing.T) {
458
464
}
459
465
460
466
func TestMaroto_GetCurrentConfig (t * testing.T ) {
461
- t .Run ("When GetCurrentConfig is called then current settings are returned " , func (t * testing.T ) {
467
+ t .Run ("When GetCurrentConfig is called, should return the current settings " , func (t * testing.T ) {
462
468
sut := maroto .New (config .NewBuilder ().
463
469
WithMaxGridSize (20 ).
464
470
Build ())
0 commit comments