@@ -5,6 +5,8 @@ import * as flow from 'dropflow';
55import parse from 'dropflow/parse.js' ;
66import { mock } from './util.js' ;
77import { clearImageCache , Image } from '../src/layout-image.ts' ;
8+ import paint from '../src/paint.ts' ;
9+ import PaintSpy from './paint-spy.js' ;
810import fs from 'node:fs' ;
911
1012const url = filename => new URL ( import . meta. resolve ( `#assets/${ filename } ` ) ) ;
@@ -114,16 +116,19 @@ describe('Hyperscript API', function () {
114116 const layout = flow . layout ( tree ) ;
115117 registerFontAsset ( 'Arimo/Arimo-Regular.ttf' ) ;
116118 flow . reflow ( layout , 100 ) ;
119+ const b = new PaintSpy ( layout ) ;
120+ paint ( layout , b ) ;
121+
122+ expect ( b . getCalls ( ) ) . to . deep . equal ( [
123+ { t : 'text' , x : 0 , y : 13.466796875 , text : 'Chapter 1' , fillColor : '#000' } ,
124+ { t : 'text' , x : 0 , y : 33.466796875 , text : 'The quick brown fox' , fillColor : '#000' } ,
125+ { t : 'text' , x : 0 , y : 53.466796875 , text : 'jumps over the lazy' , fillColor : '#000' } ,
126+ { t : 'text' , x : 0 , y : 73.466796875 , text : 'dog' , fillColor : '#000' } ,
127+ { t : 'text' , x : 0 , y : 93.466796875 , text : 'The end' , fillColor : '#000' }
128+ ] ) ;
129+
117130 const [ block ] = tree . query ( '#t' ) . boxes ;
118- expect ( block . lineboxes ) . to . have . lengthOf ( 4 ) ;
119- expect ( block . lineboxes [ 0 ] . blockOffset ) . to . equal ( 0 ) ;
120- expect ( block . lineboxes [ 1 ] . startOffset ) . to . equal ( 20 ) ;
121- expect ( block . lineboxes [ 1 ] . blockOffset ) . to . equal ( 20 ) ;
122- expect ( block . lineboxes [ 2 ] . startOffset ) . to . equal ( 40 ) ;
123- expect ( block . lineboxes [ 2 ] . blockOffset ) . to . equal ( 40 ) ;
124- expect ( block . lineboxes [ 3 ] . startOffset ) . to . equal ( 43 ) ;
125- expect ( block . lineboxes [ 3 ] . blockOffset ) . to . equal ( 60 ) ;
126- expect ( block . getLineboxHeight ( ) ) . to . equal ( 80 ) ;
131+ expect ( block . getContentArea ( ) . height ) . to . equal ( 80 ) ;
127132 unregisterFontAsset ( 'Arimo/Arimo-Regular.ttf' ) ;
128133 } ) ;
129134
@@ -132,7 +137,7 @@ describe('Hyperscript API', function () {
132137 const tree = flow . dom ( [
133138 flow . h ( 'div' , { style} , [
134139 flow . h ( 'div' , 'Chapter 1' ) ,
135- flow . h ( 'div' , { attrs : { id : 't' } } , [
140+ flow . h ( 'div' , [
136141 'The quick brown fox jumps over the lazy dog' ,
137142 flow . h ( 'br' ) ,
138143 'The end'
@@ -144,8 +149,15 @@ describe('Hyperscript API', function () {
144149 registerFontAsset ( 'Arimo/Arimo-Regular.ttf' ) ;
145150 flow . reflow ( layout , 100 ) ;
146151 flow . reflow ( layout , 100 ) ;
147- const [ block ] = tree . query ( '#t' ) . boxes ;
148- expect ( block . lineboxes ) . to . have . lengthOf ( 4 ) ;
152+ const b = new PaintSpy ( layout ) ;
153+ paint ( layout , b ) ;
154+ expect ( b . getCalls ( ) ) . to . deep . equal ( [
155+ { t : 'text' , x : 0 , y : 13.466796875 , text : 'Chapter 1' , fillColor : '#000' } ,
156+ { t : 'text' , x : 0 , y : 33.466796875 , text : 'The quick brown fox' , fillColor : '#000' } ,
157+ { t : 'text' , x : 0 , y : 53.466796875 , text : 'jumps over the lazy' , fillColor : '#000' } ,
158+ { t : 'text' , x : 0 , y : 73.466796875 , text : 'dog' , fillColor : '#000' } ,
159+ { t : 'text' , x : 0 , y : 93.466796875 , text : 'The end' , fillColor : '#000' }
160+ ] ) ;
149161 unregisterFontAsset ( 'Arimo/Arimo-Regular.ttf' ) ;
150162 } ) ;
151163
0 commit comments