import {render} from '@testing-library/react';
import React from 'react';
import {jsdomReactUniDriver} from '../../../jsdomReactUniDriver';
import {printDom} from '../printDom';

describe('printDom', () => {
  it('should print the dom', async () => {
    const {container} = render(
      <div>
        <button>
          <span>button-text</span>
        </button>
      </div>,
    );
    const driver = jsdomReactUniDriver(container);

    const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {
      return;
    });

    await printDom(driver.$('button'));

    const dom = consoleSpy.mock.lastCall?.[0];

    expect(dom).toContain('<button>');
    expect(dom).toContain('<span>');
    expect(dom).toContain('button-text');
    expect(dom).toContain('</span>');
    expect(dom).toContain('</button>');
  });
});
