import { describe, it, expect, beforeAll, afterEach } from 'vitest' import { clearFixture, getFixture } from '../helpers/fixture' import { EnableActivationTabsFromLocationHash } from '../../src/tab' describe('tab init from location hash', () => { let fixtureEl: HTMLElement beforeAll(() => { fixtureEl = getFixture() }) afterEach(() => { clearFixture() history.replaceState(null, '', window.location.pathname) }) it('does not throw for a tab link outside a nav', () => { fixtureEl.innerHTML = '
Lonely
' history.replaceState(null, '', '#lonely') expect(() => EnableActivationTabsFromLocationHash()).not.toThrow() }) it('activates the tab matching the hash, also from the data-tblr-toggle alias', () => { fixtureEl.innerHTML = '
' history.replaceState(null, '', '#one') EnableActivationTabsFromLocationHash() expect(fixtureEl.querySelector('[href="#one"]')!.classList.contains('active')).toBe(true) }) })