Files
adam-acs/tests/unit/utils/glob_match.spec.ts
Kevin L'HereecandCopilot d1c65dbf1e chore: initial commit — AdonisJS v7 TR-069 ACS
- Docker infrastructure (Dockerfile, docker-compose.yml, genieacs-sim)
- AdonisJS v7 app with Inertia.js + Vue 3
- MongoDB integration
- CWMP/TR-069 state machine engine
- Configuration engine with compliance tracking
- Branding: ADAM ACS (favicon, navbar, locales)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 16:46:37 +02:00

43 lines
1.5 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { matchGlob } from '../../../app/utils/glob_match.js'
describe('matchGlob', () => {
it('matches exact strings', () => {
expect(matchGlob('Sagemcom', 'Sagemcom')).toBe(true)
expect(matchGlob('Sagemcom', 'sagemcom')).toBe(false)
})
it('matches * as any sequence of characters', () => {
expect(matchGlob('Livebox*', 'Livebox5')).toBe(true)
expect(matchGlob('Livebox*', 'Livebox')).toBe(true)
expect(matchGlob('Livebox*', 'LiveboxPro')).toBe(true)
expect(matchGlob('*box', 'Livebox')).toBe(true)
expect(matchGlob('*box*', 'Livebox5')).toBe(true)
})
it('matches ? as exactly one character', () => {
expect(matchGlob('BM63?w', 'BM632w')).toBe(true)
expect(matchGlob('BM63?w', 'BM63w')).toBe(false)
expect(matchGlob('BM63?w', 'BM6312w')).toBe(false)
})
it('is case-sensitive', () => {
expect(matchGlob('Livebox*', 'livebox5')).toBe(false)
expect(matchGlob('livebox*', 'Livebox5')).toBe(false)
})
it('escapes regex special characters in pattern', () => {
expect(matchGlob('device.info', 'device.info')).toBe(true)
expect(matchGlob('device.info', 'deviceXinfo')).toBe(false)
expect(matchGlob('a+b', 'a+b')).toBe(true)
expect(matchGlob('a+b', 'aab')).toBe(false)
})
it('handles empty pattern and value', () => {
expect(matchGlob('', '')).toBe(true)
expect(matchGlob('*', '')).toBe(true)
expect(matchGlob('?', '')).toBe(false)
expect(matchGlob('', 'something')).toBe(false)
})
})