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) }) })