import React from 'react';
import { vi, beforeEach, describe, it, expect } from 'vitest';
import { render } from '@testing-library/react';
import MainBackground from '.';

describe('MainBackground', () => {
  beforeEach(() => {
    const addEventListener = vi.fn();
    const postMessage = vi.fn();
    const terminate = vi.fn();
    global.Worker = vi.fn().mockImplementation(() => ({
      addEventListener,
      postMessage,
      terminate,
    }));
  });

  it('should not blow up', () => {
    const { container } = render(<MainBackground />);
    expect(container instanceof HTMLDivElement).toBe(true);
    expect(container.children.length).toBe(1);
    expect(container.children[0].classList.contains('MuiBox-root')).toBe(true);
  });

  it('should disable padding when asked to', () => {
    const { container } = render(<MainBackground disablePadding />);
    expect(container instanceof HTMLDivElement).toBe(true);
    expect(container.children.length).toBe(1);
    expect(container.children[0].classList.contains('MuiBox-root')).toBe(true);
  });
});
