import assert from "node:assert/strict"
import { describe, it } from "node:test"
import { countPageFlowSpacers } from "./extensions/docs-page-flow-decoration.ts"

describe("docs-page-flow spacers", () => {
  const bodyAreaH = 900
  const interPageSpacer = 200

  it("inserts no spacer when content fits page 1", () => {
    assert.equal(countPageFlowSpacers([{ height: 400 }], bodyAreaH, interPageSpacer), 0)
  })

  it("inserts one spacer when a block crosses page 1", () => {
    assert.equal(
      countPageFlowSpacers([{ height: 850 }, { height: 100 }], bodyAreaH, interPageSpacer),
      1
    )
  })

  it("does not insert spacers for blocks already past page 1 boundary", () => {
    assert.equal(
      countPageFlowSpacers([{ height: 40 }, { height: 40 }], bodyAreaH, interPageSpacer),
      0
    )
  })

  it("inserts one spacer per crossing block in a layout pass", () => {
    assert.equal(
      countPageFlowSpacers([{ height: 1300 }], bodyAreaH, interPageSpacer),
      1
    )
  })
})
