|
1 | 1 | import { describe, expect, test } from 'vitest'; |
| 2 | +import { parseFloat } from '@react-pdf/fns'; |
2 | 3 |
|
3 | 4 | import resolve from '../src/resolve'; |
4 | 5 |
|
@@ -130,49 +131,49 @@ describe('resolve stylesheet text', () => { |
130 | 131 | test('should resolve line height number', () => { |
131 | 132 | const styles = resolveStyle({ lineHeight: 2 }); |
132 | 133 |
|
133 | | - expect(styles.lineHeight).toBe(18 * 2); |
| 134 | + expect(styles.lineHeight).toBe(`${18 * 2}pt`); |
134 | 135 | }); |
135 | 136 |
|
136 | 137 | test('should resolve number line height with font size', () => { |
137 | 138 | const styles = resolveStyle({ lineHeight: 2, fontSize: 10 }); |
138 | 139 |
|
139 | | - expect(styles.lineHeight).toBe(10 * 2); |
| 140 | + expect(styles.lineHeight).toBe(`${10 * 2}pt`); |
140 | 141 | }); |
141 | 142 |
|
142 | 143 | test('should resolve string line height', () => { |
143 | 144 | const styles = resolveStyle({ lineHeight: '2' }); |
144 | 145 |
|
145 | | - expect(styles.lineHeight).toBe(18 * 2); |
| 146 | + expect(styles.lineHeight).toBe(`${18 * 2}pt`); |
146 | 147 | }); |
147 | 148 |
|
148 | 149 | test('should resolve string line height with font-size', () => { |
149 | 150 | const styles = resolveStyle({ lineHeight: '2', fontSize: 10 }); |
150 | 151 |
|
151 | | - expect(styles.lineHeight).toBe(10 * 2); |
| 152 | + expect(styles.lineHeight).toBe(`${10 * 2}pt`); |
152 | 153 | }); |
153 | 154 |
|
154 | 155 | test('should resolve percentage line height', () => { |
155 | 156 | const styles = resolveStyle({ lineHeight: '200%' }); |
156 | 157 |
|
157 | | - expect(styles.lineHeight).toBe(18 * 2); |
| 158 | + expect(styles.lineHeight).toBe(`${18 * 2}pt`); |
158 | 159 | }); |
159 | 160 |
|
160 | 161 | test('should resolve percentage line height with font-size', () => { |
161 | 162 | const styles = resolveStyle({ lineHeight: '200%', fontSize: 10 }); |
162 | 163 |
|
163 | | - expect(styles.lineHeight).toBe(10 * 2); |
| 164 | + expect(styles.lineHeight).toBe(`${10 * 2}pt`); |
164 | 165 | }); |
165 | 166 |
|
166 | 167 | test('should resolve px line height', () => { |
167 | 168 | const styles = resolveStyle({ lineHeight: '20px' }); |
168 | 169 |
|
169 | | - expect(styles.lineHeight).toBe(20); |
| 170 | + expect(styles.lineHeight).toBe(`${20}pt`); |
170 | 171 | }); |
171 | 172 |
|
172 | 173 | test('should resolve mm line height', () => { |
173 | 174 | const styles = resolveStyle({ lineHeight: '20mm' }); |
174 | 175 |
|
175 | | - expect(styles.lineHeight).toBeCloseTo(56.69, 1); |
| 176 | + expect(parseFloat(styles.lineHeight)).toBeCloseTo(56.69, 1); |
176 | 177 | }); |
177 | 178 |
|
178 | 179 | test('should resolve font family', () => { |
@@ -328,13 +329,13 @@ describe('resolve stylesheet text', () => { |
328 | 329 | test('should resolve line height rem units', () => { |
329 | 330 | const styles = resolveStyle({ lineHeight: '2rem' }); |
330 | 331 |
|
331 | | - expect(styles).toEqual({ lineHeight: 20 }); |
| 332 | + expect(styles).toEqual({ lineHeight: '20pt' }); |
332 | 333 | }); |
333 | 334 |
|
334 | 335 | test('should resolve line height in units', () => { |
335 | 336 | const styles = resolveStyle({ lineHeight: '0.5in' }); |
336 | 337 |
|
337 | | - expect(styles).toEqual({ lineHeight: 36 }); |
| 338 | + expect(styles).toEqual({ lineHeight: '36pt' }); |
338 | 339 | }); |
339 | 340 |
|
340 | 341 | test('should resolve string max lines', () => { |
|
0 commit comments