@pyreon/document-primitives 0.11.5 → 0.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,105 +1,43 @@
1
- import { popContext, pushContext } from "@pyreon/core"
2
- import { context } from "@pyreon/rocketstyle"
3
- import { config } from "@pyreon/ui-core"
4
- import { afterAll, beforeAll, describe, expect, it } from "vitest"
5
-
6
- // Mock styled function that returns the component unchanged
7
- const mockStyled = (component: any) => {
8
- const taggedTemplate = (_strings: any, ..._args: any[]) => component
9
- return taggedTemplate
10
- }
11
-
12
- const mockCss = (_strings: any, ..._args: any[]) => ""
13
-
14
- const originalStyled = config.styled
15
- const originalCss = config.css
1
+ import { initTestConfig, renderProps } from '@pyreon/test-utils'
2
+ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
16
3
 
4
+ let cleanup: () => void
17
5
  beforeAll(() => {
18
- config.init({
19
- css: mockCss as any,
20
- styled: mockStyled as any,
21
- component: "div",
22
- textComponent: "span",
23
- })
24
- })
25
-
26
- afterAll(() => {
27
- config.styled = originalStyled
28
- config.css = originalCss
6
+ cleanup = initTestConfig()
29
7
  })
30
-
31
- /** Push a theme context and call fn, then pop context. */
32
- const withThemeContext = (fn: () => any) => {
33
- pushContext(
34
- new Map([
35
- [
36
- context.id,
37
- {
38
- theme: { rootSize: 16 },
39
- mode: "light",
40
- isDark: false,
41
- isLight: true,
42
- },
43
- ],
44
- ]),
45
- )
46
- try {
47
- return fn()
48
- } finally {
49
- popContext()
50
- }
51
- }
52
-
53
- /** Unwrap reactive accessors (EnhancedComponent returns a function for mode switching). */
54
- const unwrap = (val: any): any => {
55
- let result = val
56
- while (typeof result === "function" && !result.IS_ROCKETSTYLE) result = result()
57
- return result
58
- }
59
-
60
- /** Call a rocketstyle component and return its rendered VNode props. */
61
- const renderProps = (Component: any, props: Record<string, any> = {}) => {
62
- return withThemeContext(() => {
63
- const vnode = unwrap(Component(props))
64
- return vnode?.props ?? vnode
65
- })
66
- }
67
-
68
- // Helper: Text-based components convert `tag` to `as` through the Text component;
69
- // Element-based components keep `tag` as-is.
70
- // Both pass `_documentProps` through to the rendered output.
8
+ afterAll(() => cleanup())
71
9
 
72
10
  // --------------------------------------------------------
73
11
  // DocDocument (Element-based)
74
12
  // --------------------------------------------------------
75
- describe("DocDocument attrs", () => {
76
- it("sets tag to div", async () => {
77
- const DocDocument = (await import("../primitives/DocDocument")).default
78
- const result = renderProps(DocDocument, { children: "test" })
79
- expect(result.tag).toBe("div")
13
+ describe('DocDocument attrs', () => {
14
+ it('sets tag to div', async () => {
15
+ const DocDocument = (await import('../primitives/DocDocument')).default
16
+ const result = renderProps(DocDocument, { children: 'test' })
17
+ expect(result.tag).toBe('div')
80
18
  })
81
19
 
82
- it("passes title to _documentProps", async () => {
83
- const DocDocument = (await import("../primitives/DocDocument")).default
84
- const result = renderProps(DocDocument, { title: "My Doc", children: "test" })
85
- expect(result._documentProps.title).toBe("My Doc")
20
+ it('passes title to _documentProps', async () => {
21
+ const DocDocument = (await import('../primitives/DocDocument')).default
22
+ const result = renderProps(DocDocument, { title: 'My Doc', children: 'test' })
23
+ expect(result._documentProps.title).toBe('My Doc')
86
24
  })
87
25
 
88
- it("passes author to _documentProps", async () => {
89
- const DocDocument = (await import("../primitives/DocDocument")).default
90
- const result = renderProps(DocDocument, { author: "Jane", children: "test" })
91
- expect(result._documentProps.author).toBe("Jane")
26
+ it('passes author to _documentProps', async () => {
27
+ const DocDocument = (await import('../primitives/DocDocument')).default
28
+ const result = renderProps(DocDocument, { author: 'Jane', children: 'test' })
29
+ expect(result._documentProps.author).toBe('Jane')
92
30
  })
93
31
 
94
- it("passes subject to _documentProps", async () => {
95
- const DocDocument = (await import("../primitives/DocDocument")).default
96
- const result = renderProps(DocDocument, { subject: "Report", children: "test" })
97
- expect(result._documentProps.subject).toBe("Report")
32
+ it('passes subject to _documentProps', async () => {
33
+ const DocDocument = (await import('../primitives/DocDocument')).default
34
+ const result = renderProps(DocDocument, { subject: 'Report', children: 'test' })
35
+ expect(result._documentProps.subject).toBe('Report')
98
36
  })
99
37
 
100
- it("omits missing optional fields from _documentProps", async () => {
101
- const DocDocument = (await import("../primitives/DocDocument")).default
102
- const result = renderProps(DocDocument, { children: "test" })
38
+ it('omits missing optional fields from _documentProps', async () => {
39
+ const DocDocument = (await import('../primitives/DocDocument')).default
40
+ const result = renderProps(DocDocument, { children: 'test' })
103
41
  expect(result._documentProps).toEqual({})
104
42
  })
105
43
  })
@@ -107,25 +45,25 @@ describe("DocDocument attrs", () => {
107
45
  // --------------------------------------------------------
108
46
  // DocHeading (Text-based: tag -> as)
109
47
  // --------------------------------------------------------
110
- describe("DocHeading attrs", () => {
111
- it("defaults to h1", async () => {
112
- const DocHeading = (await import("../primitives/DocHeading")).default
113
- const result = renderProps(DocHeading, { children: "Hello" })
114
- expect(result.as).toBe("h1")
48
+ describe('DocHeading attrs', () => {
49
+ it('defaults to h1', async () => {
50
+ const DocHeading = (await import('../primitives/DocHeading')).default
51
+ const result = renderProps(DocHeading, { children: 'Hello' })
52
+ expect(result.as).toBe('h1')
115
53
  expect(result._documentProps.level).toBe(1)
116
54
  })
117
55
 
118
- it("sets tag to h2 when level is h2", async () => {
119
- const DocHeading = (await import("../primitives/DocHeading")).default
120
- const result = renderProps(DocHeading, { level: "h2", children: "Hello" })
121
- expect(result.as).toBe("h2")
56
+ it('sets tag to h2 when level is h2', async () => {
57
+ const DocHeading = (await import('../primitives/DocHeading')).default
58
+ const result = renderProps(DocHeading, { level: 'h2', children: 'Hello' })
59
+ expect(result.as).toBe('h2')
122
60
  expect(result._documentProps.level).toBe(2)
123
61
  })
124
62
 
125
- it("parses level h6", async () => {
126
- const DocHeading = (await import("../primitives/DocHeading")).default
127
- const result = renderProps(DocHeading, { level: "h6", children: "Hello" })
128
- expect(result.as).toBe("h6")
63
+ it('parses level h6', async () => {
64
+ const DocHeading = (await import('../primitives/DocHeading')).default
65
+ const result = renderProps(DocHeading, { level: 'h6', children: 'Hello' })
66
+ expect(result.as).toBe('h6')
129
67
  expect(result._documentProps.level).toBe(6)
130
68
  })
131
69
  })
@@ -133,11 +71,11 @@ describe("DocHeading attrs", () => {
133
71
  // --------------------------------------------------------
134
72
  // DocText (Text-based: tag -> as)
135
73
  // --------------------------------------------------------
136
- describe("DocText attrs", () => {
137
- it("sets tag to p", async () => {
138
- const DocText = (await import("../primitives/DocText")).default
139
- const result = renderProps(DocText, { children: "Hello" })
140
- expect(result.as).toBe("p")
74
+ describe('DocText attrs', () => {
75
+ it('sets tag to p', async () => {
76
+ const DocText = (await import('../primitives/DocText')).default
77
+ const result = renderProps(DocText, { children: 'Hello' })
78
+ expect(result.as).toBe('p')
141
79
  expect(result._documentProps).toEqual({})
142
80
  })
143
81
  })
@@ -145,66 +83,66 @@ describe("DocText attrs", () => {
145
83
  // --------------------------------------------------------
146
84
  // DocLink (Text-based: tag -> as)
147
85
  // --------------------------------------------------------
148
- describe("DocLink attrs", () => {
149
- it("sets tag to a", async () => {
150
- const DocLink = (await import("../primitives/DocLink")).default
151
- const result = renderProps(DocLink, { children: "Click" })
152
- expect(result.as).toBe("a")
86
+ describe('DocLink attrs', () => {
87
+ it('sets tag to a', async () => {
88
+ const DocLink = (await import('../primitives/DocLink')).default
89
+ const result = renderProps(DocLink, { children: 'Click' })
90
+ expect(result.as).toBe('a')
153
91
  })
154
92
 
155
- it("passes href to _documentProps", async () => {
156
- const DocLink = (await import("../primitives/DocLink")).default
157
- const result = renderProps(DocLink, { href: "https://example.com", children: "Click" })
158
- expect(result._documentProps.href).toBe("https://example.com")
93
+ it('passes href to _documentProps', async () => {
94
+ const DocLink = (await import('../primitives/DocLink')).default
95
+ const result = renderProps(DocLink, { href: 'https://example.com', children: 'Click' })
96
+ expect(result._documentProps.href).toBe('https://example.com')
159
97
  })
160
98
 
161
- it("defaults href to # when not provided", async () => {
162
- const DocLink = (await import("../primitives/DocLink")).default
163
- const result = renderProps(DocLink, { children: "Click" })
164
- expect(result._documentProps.href).toBe("#")
99
+ it('defaults href to # when not provided', async () => {
100
+ const DocLink = (await import('../primitives/DocLink')).default
101
+ const result = renderProps(DocLink, { children: 'Click' })
102
+ expect(result._documentProps.href).toBe('#')
165
103
  })
166
104
  })
167
105
 
168
106
  // --------------------------------------------------------
169
107
  // DocImage (Element-based)
170
108
  // --------------------------------------------------------
171
- describe("DocImage attrs", () => {
172
- it("sets tag to img", async () => {
173
- const DocImage = (await import("../primitives/DocImage")).default
109
+ describe('DocImage attrs', () => {
110
+ it('sets tag to img', async () => {
111
+ const DocImage = (await import('../primitives/DocImage')).default
174
112
  const result = renderProps(DocImage, { children: null })
175
- expect(result.tag).toBe("img")
113
+ expect(result.tag).toBe('img')
176
114
  })
177
115
 
178
- it("passes src to _documentProps", async () => {
179
- const DocImage = (await import("../primitives/DocImage")).default
180
- const result = renderProps(DocImage, { src: "photo.png", children: null })
181
- expect(result._documentProps.src).toBe("photo.png")
116
+ it('passes src to _documentProps', async () => {
117
+ const DocImage = (await import('../primitives/DocImage')).default
118
+ const result = renderProps(DocImage, { src: 'photo.png', children: null })
119
+ expect(result._documentProps.src).toBe('photo.png')
182
120
  })
183
121
 
184
- it("defaults src to empty string", async () => {
185
- const DocImage = (await import("../primitives/DocImage")).default
122
+ it('defaults src to empty string', async () => {
123
+ const DocImage = (await import('../primitives/DocImage')).default
186
124
  const result = renderProps(DocImage, { children: null })
187
- expect(result._documentProps.src).toBe("")
125
+ expect(result._documentProps.src).toBe('')
188
126
  })
189
127
 
190
- it("passes alt, width, height, caption when provided", async () => {
191
- const DocImage = (await import("../primitives/DocImage")).default
128
+ it('passes alt, width, height, caption when provided', async () => {
129
+ const DocImage = (await import('../primitives/DocImage')).default
192
130
  const result = renderProps(DocImage, {
193
- src: "photo.png",
194
- alt: "A photo",
131
+ src: 'photo.png',
132
+ alt: 'A photo',
195
133
  width: 200,
196
134
  height: 100,
197
- caption: "My photo",
135
+ caption: 'My photo',
198
136
  children: null,
199
137
  })
200
- expect(result._documentProps.alt).toBe("A photo")
138
+ expect(result._documentProps.alt).toBe('A photo')
201
139
  expect(result._documentProps.width).toBe(200)
202
140
  expect(result._documentProps.height).toBe(100)
203
- expect(result._documentProps.caption).toBe("My photo")
141
+ expect(result._documentProps.caption).toBe('My photo')
204
142
  })
205
143
 
206
- it("omits alt, width, height, caption when not provided", async () => {
207
- const DocImage = (await import("../primitives/DocImage")).default
144
+ it('omits alt, width, height, caption when not provided', async () => {
145
+ const DocImage = (await import('../primitives/DocImage')).default
208
146
  const result = renderProps(DocImage, { children: null })
209
147
  expect(result._documentProps.alt).toBeUndefined()
210
148
  expect(result._documentProps.width).toBeUndefined()
@@ -216,59 +154,59 @@ describe("DocImage attrs", () => {
216
154
  // --------------------------------------------------------
217
155
  // DocTable (Element-based)
218
156
  // --------------------------------------------------------
219
- describe("DocTable attrs", () => {
220
- it("sets tag to table", async () => {
221
- const DocTable = (await import("../primitives/DocTable")).default
157
+ describe('DocTable attrs', () => {
158
+ it('sets tag to table', async () => {
159
+ const DocTable = (await import('../primitives/DocTable')).default
222
160
  const result = renderProps(DocTable, { children: null })
223
- expect(result.tag).toBe("table")
161
+ expect(result.tag).toBe('table')
224
162
  })
225
163
 
226
- it("defaults columns and rows to empty arrays", async () => {
227
- const DocTable = (await import("../primitives/DocTable")).default
164
+ it('defaults columns and rows to empty arrays', async () => {
165
+ const DocTable = (await import('../primitives/DocTable')).default
228
166
  const result = renderProps(DocTable, { children: null })
229
167
  expect(result._documentProps.columns).toEqual([])
230
168
  expect(result._documentProps.rows).toEqual([])
231
169
  })
232
170
 
233
- it("passes all table options when provided", async () => {
234
- const DocTable = (await import("../primitives/DocTable")).default
171
+ it('passes all table options when provided', async () => {
172
+ const DocTable = (await import('../primitives/DocTable')).default
235
173
  const result = renderProps(DocTable, {
236
- columns: [{ header: "Name" }],
237
- rows: [["Alice"]],
238
- headerStyle: { fontWeight: "bold" },
174
+ columns: [{ header: 'Name' }],
175
+ rows: [['Alice']],
176
+ headerStyle: { fontWeight: 'bold' },
239
177
  striped: true,
240
178
  bordered: true,
241
- caption: "Users",
179
+ caption: 'Users',
242
180
  children: null,
243
181
  })
244
- expect(result._documentProps.columns).toEqual([{ header: "Name" }])
245
- expect(result._documentProps.rows).toEqual([["Alice"]])
246
- expect(result._documentProps.headerStyle).toEqual({ fontWeight: "bold" })
182
+ expect(result._documentProps.columns).toEqual([{ header: 'Name' }])
183
+ expect(result._documentProps.rows).toEqual([['Alice']])
184
+ expect(result._documentProps.headerStyle).toEqual({ fontWeight: 'bold' })
247
185
  expect(result._documentProps.striped).toBe(true)
248
186
  expect(result._documentProps.bordered).toBe(true)
249
- expect(result._documentProps.caption).toBe("Users")
187
+ expect(result._documentProps.caption).toBe('Users')
250
188
  })
251
189
  })
252
190
 
253
191
  // --------------------------------------------------------
254
192
  // DocList (Element-based)
255
193
  // --------------------------------------------------------
256
- describe("DocList attrs", () => {
257
- it("sets tag to ul by default", async () => {
258
- const DocList = (await import("../primitives/DocList")).default
194
+ describe('DocList attrs', () => {
195
+ it('sets tag to ul by default', async () => {
196
+ const DocList = (await import('../primitives/DocList')).default
259
197
  const result = renderProps(DocList, { children: null })
260
- expect(result.tag).toBe("ul")
198
+ expect(result.tag).toBe('ul')
261
199
  })
262
200
 
263
- it("sets tag to ol when ordered is true", async () => {
264
- const DocList = (await import("../primitives/DocList")).default
201
+ it('sets tag to ol when ordered is true', async () => {
202
+ const DocList = (await import('../primitives/DocList')).default
265
203
  const result = renderProps(DocList, { ordered: true, children: null })
266
- expect(result.tag).toBe("ol")
204
+ expect(result.tag).toBe('ol')
267
205
  expect(result._documentProps.ordered).toBe(true)
268
206
  })
269
207
 
270
- it("has empty _documentProps when not ordered", async () => {
271
- const DocList = (await import("../primitives/DocList")).default
208
+ it('has empty _documentProps when not ordered', async () => {
209
+ const DocList = (await import('../primitives/DocList')).default
272
210
  const result = renderProps(DocList, { children: null })
273
211
  expect(result._documentProps).toEqual({})
274
212
  })
@@ -277,11 +215,11 @@ describe("DocList attrs", () => {
277
215
  // --------------------------------------------------------
278
216
  // DocListItem (Text-based: tag -> as)
279
217
  // --------------------------------------------------------
280
- describe("DocListItem attrs", () => {
281
- it("sets tag to li", async () => {
282
- const DocListItem = (await import("../primitives/DocListItem")).default
283
- const result = renderProps(DocListItem, { children: "item" })
284
- expect(result.as).toBe("li")
218
+ describe('DocListItem attrs', () => {
219
+ it('sets tag to li', async () => {
220
+ const DocListItem = (await import('../primitives/DocListItem')).default
221
+ const result = renderProps(DocListItem, { children: 'item' })
222
+ expect(result.as).toBe('li')
285
223
  expect(result._documentProps).toEqual({})
286
224
  })
287
225
  })
@@ -289,22 +227,22 @@ describe("DocListItem attrs", () => {
289
227
  // --------------------------------------------------------
290
228
  // DocCode (Text-based: tag -> as)
291
229
  // --------------------------------------------------------
292
- describe("DocCode attrs", () => {
293
- it("sets tag to pre", async () => {
294
- const DocCode = (await import("../primitives/DocCode")).default
295
- const result = renderProps(DocCode, { children: "code" })
296
- expect(result.as).toBe("pre")
230
+ describe('DocCode attrs', () => {
231
+ it('sets tag to pre', async () => {
232
+ const DocCode = (await import('../primitives/DocCode')).default
233
+ const result = renderProps(DocCode, { children: 'code' })
234
+ expect(result.as).toBe('pre')
297
235
  })
298
236
 
299
- it("passes language to _documentProps when provided", async () => {
300
- const DocCode = (await import("../primitives/DocCode")).default
301
- const result = renderProps(DocCode, { language: "typescript", children: "code" })
302
- expect(result._documentProps.language).toBe("typescript")
237
+ it('passes language to _documentProps when provided', async () => {
238
+ const DocCode = (await import('../primitives/DocCode')).default
239
+ const result = renderProps(DocCode, { language: 'typescript', children: 'code' })
240
+ expect(result._documentProps.language).toBe('typescript')
303
241
  })
304
242
 
305
- it("has empty _documentProps when no language", async () => {
306
- const DocCode = (await import("../primitives/DocCode")).default
307
- const result = renderProps(DocCode, { children: "code" })
243
+ it('has empty _documentProps when no language', async () => {
244
+ const DocCode = (await import('../primitives/DocCode')).default
245
+ const result = renderProps(DocCode, { children: 'code' })
308
246
  expect(result._documentProps).toEqual({})
309
247
  })
310
248
  })
@@ -312,22 +250,22 @@ describe("DocCode attrs", () => {
312
250
  // --------------------------------------------------------
313
251
  // DocDivider (Element-based)
314
252
  // --------------------------------------------------------
315
- describe("DocDivider attrs", () => {
316
- it("sets tag to hr", async () => {
317
- const DocDivider = (await import("../primitives/DocDivider")).default
253
+ describe('DocDivider attrs', () => {
254
+ it('sets tag to hr', async () => {
255
+ const DocDivider = (await import('../primitives/DocDivider')).default
318
256
  const result = renderProps(DocDivider, { children: null })
319
- expect(result.tag).toBe("hr")
257
+ expect(result.tag).toBe('hr')
320
258
  })
321
259
 
322
- it("passes color and thickness when provided", async () => {
323
- const DocDivider = (await import("../primitives/DocDivider")).default
324
- const result = renderProps(DocDivider, { color: "red", thickness: 2, children: null })
325
- expect(result._documentProps.color).toBe("red")
260
+ it('passes color and thickness when provided', async () => {
261
+ const DocDivider = (await import('../primitives/DocDivider')).default
262
+ const result = renderProps(DocDivider, { color: 'red', thickness: 2, children: null })
263
+ expect(result._documentProps.color).toBe('red')
326
264
  expect(result._documentProps.thickness).toBe(2)
327
265
  })
328
266
 
329
- it("omits color and thickness when not provided", async () => {
330
- const DocDivider = (await import("../primitives/DocDivider")).default
267
+ it('omits color and thickness when not provided', async () => {
268
+ const DocDivider = (await import('../primitives/DocDivider')).default
331
269
  const result = renderProps(DocDivider, { children: null })
332
270
  expect(result._documentProps).toEqual({})
333
271
  })
@@ -336,27 +274,27 @@ describe("DocDivider attrs", () => {
336
274
  // --------------------------------------------------------
337
275
  // DocPage (Element-based)
338
276
  // --------------------------------------------------------
339
- describe("DocPage attrs", () => {
340
- it("sets tag to div", async () => {
341
- const DocPage = (await import("../primitives/DocPage")).default
342
- const result = renderProps(DocPage, { children: "page" })
343
- expect(result.tag).toBe("div")
277
+ describe('DocPage attrs', () => {
278
+ it('sets tag to div', async () => {
279
+ const DocPage = (await import('../primitives/DocPage')).default
280
+ const result = renderProps(DocPage, { children: 'page' })
281
+ expect(result.tag).toBe('div')
344
282
  })
345
283
 
346
- it("passes size and orientation when provided", async () => {
347
- const DocPage = (await import("../primitives/DocPage")).default
284
+ it('passes size and orientation when provided', async () => {
285
+ const DocPage = (await import('../primitives/DocPage')).default
348
286
  const result = renderProps(DocPage, {
349
- size: "A4",
350
- orientation: "landscape",
351
- children: "page",
287
+ size: 'A4',
288
+ orientation: 'landscape',
289
+ children: 'page',
352
290
  })
353
- expect(result._documentProps.size).toBe("A4")
354
- expect(result._documentProps.orientation).toBe("landscape")
291
+ expect(result._documentProps.size).toBe('A4')
292
+ expect(result._documentProps.orientation).toBe('landscape')
355
293
  })
356
294
 
357
- it("omits size and orientation when not provided", async () => {
358
- const DocPage = (await import("../primitives/DocPage")).default
359
- const result = renderProps(DocPage, { children: "page" })
295
+ it('omits size and orientation when not provided', async () => {
296
+ const DocPage = (await import('../primitives/DocPage')).default
297
+ const result = renderProps(DocPage, { children: 'page' })
360
298
  expect(result._documentProps).toEqual({})
361
299
  })
362
300
  })
@@ -364,11 +302,11 @@ describe("DocPage attrs", () => {
364
302
  // --------------------------------------------------------
365
303
  // DocPageBreak (Element-based)
366
304
  // --------------------------------------------------------
367
- describe("DocPageBreak attrs", () => {
368
- it("sets tag to div with empty _documentProps", async () => {
369
- const DocPageBreak = (await import("../primitives/DocPageBreak")).default
305
+ describe('DocPageBreak attrs', () => {
306
+ it('sets tag to div with empty _documentProps', async () => {
307
+ const DocPageBreak = (await import('../primitives/DocPageBreak')).default
370
308
  const result = renderProps(DocPageBreak, { children: null })
371
- expect(result.tag).toBe("div")
309
+ expect(result.tag).toBe('div')
372
310
  expect(result._documentProps).toEqual({})
373
311
  })
374
312
  })
@@ -376,22 +314,22 @@ describe("DocPageBreak attrs", () => {
376
314
  // --------------------------------------------------------
377
315
  // DocQuote (Element-based)
378
316
  // --------------------------------------------------------
379
- describe("DocQuote attrs", () => {
380
- it("sets tag to blockquote", async () => {
381
- const DocQuote = (await import("../primitives/DocQuote")).default
382
- const result = renderProps(DocQuote, { children: "quote" })
383
- expect(result.tag).toBe("blockquote")
317
+ describe('DocQuote attrs', () => {
318
+ it('sets tag to blockquote', async () => {
319
+ const DocQuote = (await import('../primitives/DocQuote')).default
320
+ const result = renderProps(DocQuote, { children: 'quote' })
321
+ expect(result.tag).toBe('blockquote')
384
322
  })
385
323
 
386
- it("passes borderColor when provided", async () => {
387
- const DocQuote = (await import("../primitives/DocQuote")).default
388
- const result = renderProps(DocQuote, { borderColor: "#ff0000", children: "quote" })
389
- expect(result._documentProps.borderColor).toBe("#ff0000")
324
+ it('passes borderColor when provided', async () => {
325
+ const DocQuote = (await import('../primitives/DocQuote')).default
326
+ const result = renderProps(DocQuote, { borderColor: '#ff0000', children: 'quote' })
327
+ expect(result._documentProps.borderColor).toBe('#ff0000')
390
328
  })
391
329
 
392
- it("has empty _documentProps when no borderColor", async () => {
393
- const DocQuote = (await import("../primitives/DocQuote")).default
394
- const result = renderProps(DocQuote, { children: "quote" })
330
+ it('has empty _documentProps when no borderColor', async () => {
331
+ const DocQuote = (await import('../primitives/DocQuote')).default
332
+ const result = renderProps(DocQuote, { children: 'quote' })
395
333
  expect(result._documentProps).toEqual({})
396
334
  })
397
335
  })
@@ -399,11 +337,11 @@ describe("DocQuote attrs", () => {
399
337
  // --------------------------------------------------------
400
338
  // DocRow (Element-based)
401
339
  // --------------------------------------------------------
402
- describe("DocRow attrs", () => {
403
- it("sets tag to div with empty _documentProps", async () => {
404
- const DocRow = (await import("../primitives/DocRow")).default
340
+ describe('DocRow attrs', () => {
341
+ it('sets tag to div with empty _documentProps', async () => {
342
+ const DocRow = (await import('../primitives/DocRow')).default
405
343
  const result = renderProps(DocRow, { children: null })
406
- expect(result.tag).toBe("div")
344
+ expect(result.tag).toBe('div')
407
345
  expect(result._documentProps).toEqual({})
408
346
  })
409
347
  })
@@ -411,21 +349,21 @@ describe("DocRow attrs", () => {
411
349
  // --------------------------------------------------------
412
350
  // DocColumn (Element-based)
413
351
  // --------------------------------------------------------
414
- describe("DocColumn attrs", () => {
415
- it("sets tag to div", async () => {
416
- const DocColumn = (await import("../primitives/DocColumn")).default
352
+ describe('DocColumn attrs', () => {
353
+ it('sets tag to div', async () => {
354
+ const DocColumn = (await import('../primitives/DocColumn')).default
417
355
  const result = renderProps(DocColumn, { children: null })
418
- expect(result.tag).toBe("div")
356
+ expect(result.tag).toBe('div')
419
357
  })
420
358
 
421
- it("passes width to _documentProps when provided", async () => {
422
- const DocColumn = (await import("../primitives/DocColumn")).default
423
- const result = renderProps(DocColumn, { width: "50%", children: null })
424
- expect(result._documentProps.width).toBe("50%")
359
+ it('passes width to _documentProps when provided', async () => {
360
+ const DocColumn = (await import('../primitives/DocColumn')).default
361
+ const result = renderProps(DocColumn, { width: '50%', children: null })
362
+ expect(result._documentProps.width).toBe('50%')
425
363
  })
426
364
 
427
- it("has empty _documentProps when no width", async () => {
428
- const DocColumn = (await import("../primitives/DocColumn")).default
365
+ it('has empty _documentProps when no width', async () => {
366
+ const DocColumn = (await import('../primitives/DocColumn')).default
429
367
  const result = renderProps(DocColumn, { children: null })
430
368
  expect(result._documentProps).toEqual({})
431
369
  })
@@ -434,21 +372,21 @@ describe("DocColumn attrs", () => {
434
372
  // --------------------------------------------------------
435
373
  // DocSpacer (Element-based)
436
374
  // --------------------------------------------------------
437
- describe("DocSpacer attrs", () => {
438
- it("sets tag to div", async () => {
439
- const DocSpacer = (await import("../primitives/DocSpacer")).default
375
+ describe('DocSpacer attrs', () => {
376
+ it('sets tag to div', async () => {
377
+ const DocSpacer = (await import('../primitives/DocSpacer')).default
440
378
  const result = renderProps(DocSpacer, { children: null })
441
- expect(result.tag).toBe("div")
379
+ expect(result.tag).toBe('div')
442
380
  })
443
381
 
444
- it("defaults height to 16", async () => {
445
- const DocSpacer = (await import("../primitives/DocSpacer")).default
382
+ it('defaults height to 16', async () => {
383
+ const DocSpacer = (await import('../primitives/DocSpacer')).default
446
384
  const result = renderProps(DocSpacer, { children: null })
447
385
  expect(result._documentProps.height).toBe(16)
448
386
  })
449
387
 
450
- it("passes custom height", async () => {
451
- const DocSpacer = (await import("../primitives/DocSpacer")).default
388
+ it('passes custom height', async () => {
389
+ const DocSpacer = (await import('../primitives/DocSpacer')).default
452
390
  const result = renderProps(DocSpacer, { height: 32, children: null })
453
391
  expect(result._documentProps.height).toBe(32)
454
392
  })
@@ -457,73 +395,73 @@ describe("DocSpacer attrs", () => {
457
395
  // --------------------------------------------------------
458
396
  // DocSection (Element-based)
459
397
  // --------------------------------------------------------
460
- describe("DocSection attrs", () => {
461
- it("sets tag to div", async () => {
462
- const DocSection = (await import("../primitives/DocSection")).default
398
+ describe('DocSection attrs', () => {
399
+ it('sets tag to div', async () => {
400
+ const DocSection = (await import('../primitives/DocSection')).default
463
401
  const result = renderProps(DocSection, { children: null })
464
- expect(result.tag).toBe("div")
402
+ expect(result.tag).toBe('div')
465
403
  })
466
404
 
467
- it("defaults direction to column", async () => {
468
- const DocSection = (await import("../primitives/DocSection")).default
405
+ it('defaults direction to column', async () => {
406
+ const DocSection = (await import('../primitives/DocSection')).default
469
407
  const result = renderProps(DocSection, { children: null })
470
- expect(result._documentProps.direction).toBe("column")
408
+ expect(result._documentProps.direction).toBe('column')
471
409
  })
472
410
 
473
- it("passes direction when provided", async () => {
474
- const DocSection = (await import("../primitives/DocSection")).default
475
- const result = renderProps(DocSection, { direction: "row", children: null })
476
- expect(result._documentProps.direction).toBe("row")
411
+ it('passes direction when provided', async () => {
412
+ const DocSection = (await import('../primitives/DocSection')).default
413
+ const result = renderProps(DocSection, { direction: 'row', children: null })
414
+ expect(result._documentProps.direction).toBe('row')
477
415
  })
478
416
  })
479
417
 
480
418
  // --------------------------------------------------------
481
419
  // DocButton (Text-based: tag -> as)
482
420
  // --------------------------------------------------------
483
- describe("DocButton attrs", () => {
484
- it("sets tag to a", async () => {
485
- const DocButton = (await import("../primitives/DocButton")).default
486
- const result = renderProps(DocButton, { children: "Click" })
487
- expect(result.as).toBe("a")
421
+ describe('DocButton attrs', () => {
422
+ it('sets tag to a', async () => {
423
+ const DocButton = (await import('../primitives/DocButton')).default
424
+ const result = renderProps(DocButton, { children: 'Click' })
425
+ expect(result.as).toBe('a')
488
426
  })
489
427
 
490
- it("passes href to _documentProps", async () => {
491
- const DocButton = (await import("../primitives/DocButton")).default
492
- const result = renderProps(DocButton, { href: "https://example.com", children: "Click" })
493
- expect(result._documentProps.href).toBe("https://example.com")
428
+ it('passes href to _documentProps', async () => {
429
+ const DocButton = (await import('../primitives/DocButton')).default
430
+ const result = renderProps(DocButton, { href: 'https://example.com', children: 'Click' })
431
+ expect(result._documentProps.href).toBe('https://example.com')
494
432
  })
495
433
 
496
- it("defaults href to # when not provided", async () => {
497
- const DocButton = (await import("../primitives/DocButton")).default
498
- const result = renderProps(DocButton, { children: "Click" })
499
- expect(result._documentProps.href).toBe("#")
434
+ it('defaults href to # when not provided', async () => {
435
+ const DocButton = (await import('../primitives/DocButton')).default
436
+ const result = renderProps(DocButton, { children: 'Click' })
437
+ expect(result._documentProps.href).toBe('#')
500
438
  })
501
439
  })
502
440
 
503
441
  // --------------------------------------------------------
504
442
  // DocumentPreview (Element-based)
505
443
  // --------------------------------------------------------
506
- describe("DocumentPreview attrs", () => {
507
- it("sets tag to div", async () => {
508
- const DocumentPreview = (await import("../DocumentPreview")).default
444
+ describe('DocumentPreview attrs', () => {
445
+ it('sets tag to div', async () => {
446
+ const DocumentPreview = (await import('../DocumentPreview')).default
509
447
  const result = renderProps(DocumentPreview, { children: null })
510
- expect(result.tag).toBe("div")
448
+ expect(result.tag).toBe('div')
511
449
  })
512
450
 
513
- it("defaults size to A4 when not provided", async () => {
514
- const DocumentPreview = (await import("../DocumentPreview")).default
451
+ it('defaults size to A4 when not provided', async () => {
452
+ const DocumentPreview = (await import('../DocumentPreview')).default
515
453
  const result = renderProps(DocumentPreview, { children: null })
516
- expect(result._documentProps.size).toBe("A4")
454
+ expect(result._documentProps.size).toBe('A4')
517
455
  })
518
456
 
519
- it("passes custom size", async () => {
520
- const DocumentPreview = (await import("../DocumentPreview")).default
521
- const result = renderProps(DocumentPreview, { size: "letter", children: null })
522
- expect(result._documentProps.size).toBe("letter")
457
+ it('passes custom size', async () => {
458
+ const DocumentPreview = (await import('../DocumentPreview')).default
459
+ const result = renderProps(DocumentPreview, { size: 'letter', children: null })
460
+ expect(result._documentProps.size).toBe('letter')
523
461
  })
524
462
 
525
- it("passes showPageBreaks when provided", async () => {
526
- const DocumentPreview = (await import("../DocumentPreview")).default
463
+ it('passes showPageBreaks when provided', async () => {
464
+ const DocumentPreview = (await import('../DocumentPreview')).default
527
465
  const result = renderProps(DocumentPreview, { showPageBreaks: true, children: null })
528
466
  expect(result._documentProps.showPageBreaks).toBe(true)
529
467
  })
@@ -532,26 +470,26 @@ describe("DocumentPreview attrs", () => {
532
470
  // --------------------------------------------------------
533
471
  // All primitives: displayName and IS_ROCKETSTYLE coverage
534
472
  // --------------------------------------------------------
535
- describe("all primitives have correct displayName and IS_ROCKETSTYLE", () => {
473
+ describe('all primitives have correct displayName and IS_ROCKETSTYLE', () => {
536
474
  const primitivePairs = [
537
- ["DocButton", "../primitives/DocButton"],
538
- ["DocCode", "../primitives/DocCode"],
539
- ["DocColumn", "../primitives/DocColumn"],
540
- ["DocDivider", "../primitives/DocDivider"],
541
- ["DocDocument", "../primitives/DocDocument"],
542
- ["DocHeading", "../primitives/DocHeading"],
543
- ["DocImage", "../primitives/DocImage"],
544
- ["DocLink", "../primitives/DocLink"],
545
- ["DocList", "../primitives/DocList"],
546
- ["DocListItem", "../primitives/DocListItem"],
547
- ["DocPage", "../primitives/DocPage"],
548
- ["DocPageBreak", "../primitives/DocPageBreak"],
549
- ["DocQuote", "../primitives/DocQuote"],
550
- ["DocRow", "../primitives/DocRow"],
551
- ["DocSection", "../primitives/DocSection"],
552
- ["DocSpacer", "../primitives/DocSpacer"],
553
- ["DocTable", "../primitives/DocTable"],
554
- ["DocText", "../primitives/DocText"],
475
+ ['DocButton', '../primitives/DocButton'],
476
+ ['DocCode', '../primitives/DocCode'],
477
+ ['DocColumn', '../primitives/DocColumn'],
478
+ ['DocDivider', '../primitives/DocDivider'],
479
+ ['DocDocument', '../primitives/DocDocument'],
480
+ ['DocHeading', '../primitives/DocHeading'],
481
+ ['DocImage', '../primitives/DocImage'],
482
+ ['DocLink', '../primitives/DocLink'],
483
+ ['DocList', '../primitives/DocList'],
484
+ ['DocListItem', '../primitives/DocListItem'],
485
+ ['DocPage', '../primitives/DocPage'],
486
+ ['DocPageBreak', '../primitives/DocPageBreak'],
487
+ ['DocQuote', '../primitives/DocQuote'],
488
+ ['DocRow', '../primitives/DocRow'],
489
+ ['DocSection', '../primitives/DocSection'],
490
+ ['DocSpacer', '../primitives/DocSpacer'],
491
+ ['DocTable', '../primitives/DocTable'],
492
+ ['DocText', '../primitives/DocText'],
555
493
  ] as const
556
494
 
557
495
  for (const [name, path] of primitivePairs) {
@@ -562,7 +500,7 @@ describe("all primitives have correct displayName and IS_ROCKETSTYLE", () => {
562
500
 
563
501
  it(`${name} is a function`, async () => {
564
502
  const mod = await import(path)
565
- expect(typeof mod.default).toBe("function")
503
+ expect(typeof mod.default).toBe('function')
566
504
  })
567
505
 
568
506
  it(`${name} has IS_ROCKETSTYLE = true`, async () => {