Skip to content

Commit

Permalink
Add tests for current page filter
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 22, 2023
1 parent a625049 commit 9ef710b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/lib/filters/current-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const assert = require('assert/strict')
const { describe, it } = require('node:test')
const currentPage = require('../../../lib/filters/current-page.js')

const navigationData = [
{ text: 'Home', href: '/' },
{ text: 'Styles', href: '/styles' }
]

describe('currentPage filter', () => {
it('Indicates the home page is current', () => {
const result = currentPage(navigationData, '/')

assert.deepEqual(result, [
{ text: 'Home', href: '/', current: true },
{ text: 'Styles', href: '/styles', current: false }
])
})

it('Indicates the section page is current', () => {
const result = currentPage(navigationData, '/styles')

assert.deepEqual(result, [
{ text: 'Home', href: '/', current: false },
{ text: 'Styles', href: '/styles', current: true }
])
})

it('Indicates the section sub page is current', () => {
const result = currentPage(navigationData, '/styles/colour')

assert.deepEqual(result, [
{ text: 'Home', href: '/', current: false },
{ text: 'Styles', href: '/styles', current: true }
])
})
})

0 comments on commit 9ef710b

Please sign in to comment.