Skip to content

Commit

Permalink
Add test case of paginate: hold for the first page
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Sep 9, 2023
1 parent 1be0a36 commit ffd3dea
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions test/markdown/directives/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe('Marpit directives apply plugin', () => {
})

describe('Paginate with skipped slides', () => {
it('applies data-marpit-pagination attribute with a _paginate:hold slide', () => {
it('applies data-marpit-pagination attribute with a _paginate: hold slide', () => {
const paginateDirs = dedent`
---
paginate: true
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('Marpit directives apply plugin', () => {
expect(sections.eq(2).data('marpit-pagination-total')).toBe(2)
})

it('applies data-marpit-pagination attribute with a _paginate:skip slide', () => {
it('applies data-marpit-pagination attribute with a _paginate: skip slide', () => {
const paginateDirs = dedent`
---
paginate: true
Expand Down Expand Up @@ -322,6 +322,58 @@ describe('Marpit directives apply plugin', () => {
expect(sections.eq(2).data('marpit-pagination')).toBe(2)
expect(sections.eq(2).data('marpit-pagination-total')).toBe(2)
})

context('when paginate: hold is applied from beginning', () => {
const paginateDirs = dedent`
---
paginate: hold
---
# Slide 1
- Page is not incremented (1 of 3)
- Pagination rendered
---
## Slide 2
- Page is not incremented (1 of 3)
- Pagination rendered
---
<!-- paginate: true -->
## Slide 3
- Page is incremented (2 of 3)
- Pagination rendered
---
<!-- paginate: false -->
## Slide 4
- Page is incremented (3 of 3)
- Pagination is not rendered
`

it('applies data-marpit-pagination and data-marpit-pagination-total attribute correctly', () => {
const $ = load(mdForTest().render(paginateDirs))
const sections = $('section')

expect(sections.eq(0).data('marpit-pagination')).toBe(1)
expect(sections.eq(0).data('marpit-pagination-total')).toBe(3)
expect(sections.eq(1).data('marpit-pagination')).toBe(1)
expect(sections.eq(1).data('marpit-pagination-total')).toBe(3)
expect(sections.eq(2).data('marpit-pagination')).toBe(2)
expect(sections.eq(2).data('marpit-pagination-total')).toBe(3)
expect(sections.eq(3).data('marpit-pagination')).toBeUndefined()
expect(sections.eq(3).data('marpit-pagination-total')).toBeUndefined()
})
})
})
})
})

0 comments on commit ffd3dea

Please sign in to comment.