Skip to content

Commit

Permalink
Add failing test for client-side router filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
crisvergara committed Dec 5, 2023
1 parent b88e263 commit e73139c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/unit/create-client-router-filter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-env jest */
import { createClientRouterFilter } from 'next/dist/lib/create-client-router-filter'
import { BloomFilter } from 'next/dist/shared/lib/bloom-filter'

describe('createClientRouterFilter', () => {
it('creates a filter that does not collide with wildly different path names', () => {
const { staticFilter, dynamicFilter } = createClientRouterFilter(
['/_not-found', '/a/[lang]/corporate', '/a/[lang]/gift'], // Routes are based on BOTM's app router migration project.
[]
)

const staticFilterInstance = new BloomFilter(
staticFilter.numItems,
staticFilter.errorRate
)
staticFilterInstance.import(staticFilter)
const dynamicFilterInstance = new BloomFilter(
dynamicFilter.numItems,
dynamicFilter.errorRate
)
dynamicFilterInstance.import(dynamicFilter)

expect(
staticFilterInstance.contains(
'/all-hardcovers/no-one-can-know-1511?category=current-features'
)
).toBe(false)
})
})

0 comments on commit e73139c

Please sign in to comment.