1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
});
});
|