Files
technitium-console/src/lib/list-count.test.ts
T
DenozordecandClaude Opus 5.5 172e06f1ce
CI / check (push) Successful in 3m7s
Hub / check (push) Successful in 53s
CI / image (push) Successful in 1m29s
Hub / image (push) Successful in 1m19s
Blocking: count Advanced Blocking, Dashboard layout and KPI cards
- Status, sidebar mark and header treat a server that blocks with the
  Advanced Blocking app as blocking, per server behind the hub.
- Overview panel summarising the app's groups; Lists and Rules show and
  edit the app's list URLs and rules (read, change one field, write back).
- Block List Domains adds the app's list domains, counted by the hub
  (hub/blocking/app-lists/count, public hosts only unless
  HUB_LISTS_ALLOW_PRIVATE=1) or by the browser where CORS allows.
- Header and KPI cards follow the Dashboard: selector in the chrome slot,
  Compare servers in the header actions, period under the title, StatCard
  tiles without sparklines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 18:34:17 +07:00

31 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { countDomains } from './list-count'
describe('countDomains', () => {
it('counts hosts lines, skipping comments and the hosts file own names', () => {
const text = [
'# Title: a list',
'127.0.0.1 localhost',
'::1 ip6-localhost',
'0.0.0.0 ads.example.com',
'0.0.0.0 track.example.com # inline',
'0.0.0.0 ads.example.com',
'',
].join('\r\n')
expect(countDomains(text)).toBe(2)
})
it('counts plain domains and wildcards once each', () => {
expect(countDomains('a.example\nB.example\n*.c.example\na.example\n! note\n')).toBe(3)
})
it('counts adblock domain rules, not exceptions, options-only lines or regexes', () => {
const text = ['[Adblock Plus 2.0]', '! Title', '||ads.example.com^', '||t.example.net^$third-party', '@@||ok.example.com^', '/banner[0-9]+/', '##.ad'].join('\n')
expect(countDomains(text)).toBe(2)
})
it('counts several names on one hosts line', () => {
expect(countDomains('0.0.0.0 a.example b.example')).toBe(2)
})
})