diff options
| author | Bertrand Yuan <189593334+bertyuan@users.noreply.github.com> | 2026-03-26 00:19:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-26 00:19:31 +0800 |
| commit | f247a8c4a863ec430f4a705b5c493d652c8429bd (patch) | |
| tree | 71d0985970984c105582f6e3c370b254f38e9bbe /src/lib/is-active.test.ts | |
| parent | f7a02fe0e112cf108fc5f22872f1efc077e99fe8 (diff) | |
| parent | cd3c4bc89c169616b38bdb7443bb4eb7571b020c (diff) | |
Merge pull request #12 from bertyuan/fix-vitestv1.1
Fix vitest
Diffstat (limited to 'src/lib/is-active.test.ts')
| -rw-r--r-- | src/lib/is-active.test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/is-active.test.ts b/src/lib/is-active.test.ts new file mode 100644 index 0000000..fcc42d0 --- /dev/null +++ b/src/lib/is-active.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, test } from 'vitest'; +import { isActive } from './is-active'; + +describe('isActive', () => { + test('returns true for exact match', () => { + expect(isActive('/posts', '/posts')).toBe(true); + }); + + test('normalizes trailing slashes before comparing', () => { + expect(isActive('/posts/', '/posts')).toBe(true); + expect(isActive('/posts', '/posts/')).toBe(true); + }); + + test('returns true for nested paths when nested is enabled', () => { + expect(isActive('/posts', '/posts/hello-world', true)).toBe(true); + }); + + test('returns false for nested paths when nested is disabled', () => { + expect(isActive('/posts', '/posts/hello-world', false)).toBe(false); + }); + + test('returns false for unrelated paths', () => { + expect(isActive('/posts', '/tags')).toBe(false); + }); +}); + |
