{"version":3,"sources":["../../src/sections/section.test.ts"],"sourcesContent":["import {\n  DocumentSection,\n  DocumentSectionOptions,\n  tryFindSection,\n} from './section.js';\n\nfunction createTestSection(options: DocumentSectionOptions) {\n  class TestSection extends DocumentSection {\n    protected synthesizeContent(): Array<string> {\n      return [options.title, ...this.subSections.map((s) => s.synthesize())];\n    }\n  }\n\n  return new TestSection(options);\n}\n\ndescribe('Test Section', () => {\n  it('should return the title', () => {\n    expect(createTestSection({ title: 'Test Section' }).synthesize()).toBe(\n      'Test Section',\n    );\n  });\n\n  it('should return the sub sections', () => {\n    const section = createTestSection({ title: 'Test Section' });\n    section.addSubSection(createTestSection({ title: 'Sub Section' }));\n    expect(section.subSections).toHaveLength(1);\n  });\n\n  it('should return the heading level', () => {\n    expect(createTestSection({ title: 'Test Section' }).headingLevel).toBe(2);\n  });\n\n  it('should add itself to the parent', () => {\n    const parent = createTestSection({ title: 'Parent Section' });\n    const child = createTestSection({ title: 'Child Section', parent });\n    expect(parent.subSections).toContain(child);\n  });\n\n  it('should return 6 if the maximum level is exceeded', () => {\n    const testSection = createTestSection({ title: 'Test Section' });\n\n    createTestSection({ title: 'Level 1' }).addSubSection(\n      createTestSection({ title: 'Level 2' }).addSubSection(\n        createTestSection({ title: 'Level 3' }).addSubSection(\n          createTestSection({ title: 'Level 4' }).addSubSection(\n            createTestSection({ title: 'Level 5' }).addSubSection(\n              createTestSection({ title: 'Level 5' }).addSubSection(\n                testSection,\n              ),\n            ),\n          ),\n        ),\n      ),\n    );\n\n    expect(testSection.headingLevel).toBe(6);\n  });\n});\n\ndescribe('tryFindSection', () => {\n  it('should return undefined when no sections are provided', () => {\n    expect(tryFindSection([], ['Test Section'])).toBeUndefined();\n  });\n\n  it('should return undefined when no sections match', () => {\n    expect(\n      tryFindSection(\n        [createTestSection({ title: 'Test Section' })],\n        ['Other Section'],\n      ),\n    ).toBeUndefined();\n  });\n\n  it('should return the section when it matches', () => {\n    const testSection = createTestSection({ title: 'Test Section' });\n    expect(tryFindSection([testSection], ['Test Section'])).toStrictEqual(\n      testSection,\n    );\n  });\n\n  it('should return the section when it matches the path', () => {\n    const testSection = createTestSection({ title: 'Test Section' });\n    const subSection = createTestSection({ title: 'Sub Section' });\n    testSection.addSubSection(subSection);\n    expect(\n      tryFindSection([testSection], ['Test Section', 'Sub Section']),\n    ).toStrictEqual(subSection);\n  });\n\n  it('should add single sub section passed in options', () => {\n    const testSection = createTestSection({\n      title: 'Test Section',\n      subSections: [createTestSection({ title: 'Sub Section' })],\n    });\n\n    expect(testSection.synthesize()).toMatchInlineSnapshot(`\n      \"Test Section\n      Sub Section\"\n    `);\n  });\n\n  it('should add multiple sub sections passed in options', () => {\n    const testSection = createTestSection({\n      title: 'Test Section',\n      subSections: [\n        createTestSection({ title: 'Sub Section 1' }),\n        createTestSection({ title: 'Sub Section 2' }),\n      ],\n    });\n\n    expect(testSection.synthesize()).toMatchInlineSnapshot(`\n      \"Test Section\n      Sub Section 1\n      Sub Section 2\"\n    `);\n  });\n});\n"],"mappings":";AAAA,qBAIO;AAEP,SAAS,kBAAkB,SAAiC;AAAA,EAC1D,MAAM,oBAAoB,+BAAgB;AAAA,IAC9B,oBAAmC;AAC3C,aAAO,CAAC,QAAQ,OAAO,GAAG,KAAK,YAAY,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAAA,IACvE;AAAA,EACF;AAEA,SAAO,IAAI,YAAY,OAAO;AAChC;AAEA,SAAS,gBAAgB,MAAM;AAC7B,KAAG,2BAA2B,MAAM;AAClC,WAAO,kBAAkB,EAAE,OAAO,eAAe,CAAC,EAAE,WAAW,CAAC,EAAE;AAAA,MAChE;AAAA,IACF;AAAA,EACF,CAAC;AAED,KAAG,kCAAkC,MAAM;AACzC,UAAM,UAAU,kBAAkB,EAAE,OAAO,eAAe,CAAC;AAC3D,YAAQ,cAAc,kBAAkB,EAAE,OAAO,cAAc,CAAC,CAAC;AACjE,WAAO,QAAQ,WAAW,EAAE,aAAa,CAAC;AAAA,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