L
${'Gauge readings, hour by hour.
\n'.repeat(6000)}`),
+ behaviors: { paywall: range('article.post', { fromMarker: 'p.lede' }) },
+ spliced: true,
+ },
+]
+
+// The splice must give exactly what the per-element path gives, and say when it stood aside.
+describe('spliceRangeReplacements', () => {
+ it.each(cases)('$name', async ({ html: page, behaviors, spliced }) => {
+ const d = decision(behaviors)
+ const expected = await (await transformComponents(ctx, html(page), d, new LolHtmlRewriter())).text()
+
+ expect((await spliceRangeReplacements(html(page), d, new LolHtmlRewriter())) !== null).toBe(spliced)
+ const result = await handleSurfaceComponents(ctx, html(page), d, new LolHtmlRewriter())
+ const actual = await result.text()
+ expect(actual).toBe(expected)
+ expect(actual).not.toContain('mos-range')
+ if (spliced) expect(result.headers.get('content-length')).toBeNull()
+ })
+})