import { describe, it, expect, beforeEach } from 'vitest';
import { parallax } from './parallax.js';
import { mountHost, connectTrait, resetDOM } from '../test-helpers.js';

describe('parallax', () => {
  beforeEach(resetDOM);

  it('connect sets data-parallax-active', () => {
    const host = mountHost();
    connectTrait(parallax, host);
    expect(host.hasAttribute('data-parallax-active')).toBe(true);
  });

  it('disconnect clears active + translate', () => {
    const host = mountHost();
    const inst = connectTrait(parallax, host);
    inst.disconnect(host);
    expect(host.hasAttribute('data-parallax-active')).toBe(false);
    expect(host.style.translate).toBe('');
  });

  it('respects data-parallax-strength (default 0.5)', () => {
    const host = mountHost('div', { 'data-parallax-strength': '0.2' });
    expect(() => connectTrait(parallax, host)).not.toThrow();
  });
});
