@@ -5,47 +5,47 @@ import resolveDimensions from '../../src/steps/resolveDimensions';
55const calcLayout = node => resolvePagination ( resolveDimensions ( node ) ) ;
66
77describe ( 'pagination step' , ( ) => {
8- const root = {
9- type : 'DOCUMENT' ,
10- children : [
11- {
12- type : 'PAGE' ,
13- box : { } ,
14- style : {
15- width : 100 ,
16- height : 100 ,
17- } ,
18- children : [
19- {
20- type : 'VIEW' ,
21- box : { } ,
22- style : {
23- position : 'absolute' ,
24- width : '50%' ,
25- top : 0 ,
26- bottom : 0 ,
27- } ,
28- props : { } ,
29- children : [ ] ,
8+ test ( 'should stretch absolute block to full page size' , ( ) => {
9+ const root = {
10+ type : 'DOCUMENT' ,
11+ children : [
12+ {
13+ type : 'PAGE' ,
14+ box : { } ,
15+ style : {
16+ width : 100 ,
17+ height : 100 ,
3018 } ,
31- {
32- type : 'TEXT' ,
33- box : { } ,
34- style : { } ,
35- props : { } ,
36- children : [
37- {
38- type : 'TEXT_INSTANCE' ,
39- value : 'hello world' ,
19+ children : [
20+ {
21+ type : 'VIEW' ,
22+ box : { } ,
23+ style : {
24+ position : 'absolute' ,
25+ width : '50%' ,
26+ top : 0 ,
27+ bottom : 0 ,
4028 } ,
41- ] ,
42- } ,
43- ] ,
44- } ,
45- ] ,
46- } ;
29+ props : { } ,
30+ children : [ ] ,
31+ } ,
32+ {
33+ type : 'TEXT' ,
34+ box : { } ,
35+ style : { } ,
36+ props : { } ,
37+ children : [
38+ {
39+ type : 'TEXT_INSTANCE' ,
40+ value : 'hello world' ,
41+ } ,
42+ ] ,
43+ } ,
44+ ] ,
45+ } ,
46+ ] ,
47+ } ;
4748
48- test ( 'should stretch absolute block to full page size' , ( ) => {
4949 const layout = calcLayout ( root ) ;
5050
5151 const page = layout . children [ 0 ] ;
@@ -54,4 +54,87 @@ describe('pagination step', () => {
5454 expect ( page . box . height ) . toBe ( 100 ) ;
5555 expect ( view . box . height ) . toBe ( 100 ) ;
5656 } ) ;
57+
58+ test ( 'should force new height for split nodes' , ( ) => {
59+ const root = {
60+ type : 'DOCUMENT' ,
61+ children : [
62+ {
63+ type : 'PAGE' ,
64+ box : { } ,
65+ style : {
66+ width : 15 ,
67+ height : 60 ,
68+ } ,
69+
70+ children : [
71+ {
72+ type : 'VIEW' ,
73+ box : { } ,
74+ style : { } ,
75+ props : { } ,
76+ children : [
77+ {
78+ type : 'TEXT' ,
79+ box : { } ,
80+ style : { } ,
81+ props : { } ,
82+ children : [
83+ {
84+ type : 'TEXT_INSTANCE' ,
85+ value : 'a a a a' ,
86+ } ,
87+ ] ,
88+ } ,
89+ ] ,
90+ } ,
91+ ] ,
92+ } ,
93+ ] ,
94+ } ;
95+
96+ const layout = calcLayout ( root ) ;
97+
98+ const view1 = layout . children [ 0 ] . children [ 0 ] ;
99+ const view2 = layout . children [ 1 ] . children [ 0 ] ;
100+
101+ expect ( view1 . box . height ) . toBe ( 60 ) ;
102+ expect ( view2 . box . height ) . not . toBe ( 60 ) ;
103+ } ) ;
104+
105+ test ( 'should force new height for split nodes with fixed height' , ( ) => {
106+ const root = {
107+ type : 'DOCUMENT' ,
108+ children : [
109+ {
110+ type : 'PAGE' ,
111+ box : { } ,
112+ style : {
113+ width : 5 ,
114+ height : 60 ,
115+ } ,
116+
117+ children : [
118+ {
119+ type : 'VIEW' ,
120+ box : { } ,
121+ style : { height : 130 } ,
122+ props : { } ,
123+ children : [ ] ,
124+ } ,
125+ ] ,
126+ } ,
127+ ] ,
128+ } ;
129+
130+ const layout = calcLayout ( root ) ;
131+
132+ const view1 = layout . children [ 0 ] . children [ 0 ] ;
133+ const view2 = layout . children [ 1 ] . children [ 0 ] ;
134+ const view3 = layout . children [ 2 ] . children [ 0 ] ;
135+
136+ expect ( view1 . box . height ) . toBe ( 60 ) ;
137+ expect ( view2 . box . height ) . toBe ( 60 ) ;
138+ expect ( view3 . box . height ) . toBe ( 10 ) ;
139+ } ) ;
57140} ) ;
0 commit comments