-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for client-side router filtering
- Loading branch information
1 parent
b88e263
commit e73139c
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |