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

describe('spring-animate', () => {
  beforeEach(resetDOM);

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

  it('disconnect clears active', () => {
    const host = mountHost();
    const inst = connectTrait(springAnimate, host);
    inst.disconnect(host);
    expect(host.hasAttribute('data-spring-animate-active')).toBe(false);
  });

  it('respects data-spring-stiffness + data-spring-damping config', () => {
    const host = mountHost('div', {
      'data-spring-stiffness': '200',
      'data-spring-damping': '0.6',
    });
    expect(() => connectTrait(springAnimate, host)).not.toThrow();
  });
});
