const { render } = require('@bolt/twig-renderer');
const buttonTemplate = '@bolt-components-button/button.twig';

describe('Test the Bolt Twig Renderer API', () => {
  test('renders a basic button', async () => {
    const buttonData = {
      text: 'Hello world!',
    };
    const result = await render(buttonTemplate, buttonData);

    expect(result.ok).toEqual(true);
  });

  test('handles missing data', async () => {
    const result = await render(buttonTemplate);

    expect(result.ok).toEqual(true);
  });

  test('handles non-existent template path', async () => {
    const result = await render('@bolt-components-button/button2.twig', {
      text: 'Hello world 2!',
    });

    expect(result.ok).toEqual(false);
  });

  test('renders the button component correctly', async () => {
    const result = await render(buttonTemplate, {
      text: 'Hello world!2',
    });

    expect(result.html).toMatchSnapshot();
  });

  test('renders attributes on the button component correctly', async () => {
    const result = await render(buttonTemplate, {
      text: 'Hello world!',
      attributes: {
        class: ['u-bolt-margin-bottom-large'],
      },
    });

    expect(result.html).toMatchSnapshot();
  });

  test('renders the secondary button correctly', async () => {
    const result = await render(buttonTemplate, {
      text: 'Secondary Button!',
      style: 'secondary',
    });

    expect(result.html).toMatchSnapshot();
  });
});

@@ -360,35 +360,42 @@
 Equal(true);%0A  %7D
+, 10000
 );%0A
-
 %0A  test('handles
@@ -510,24 +510,31 @@
 l(true);%0A  %7D
+, 10000
 );%0A%0A  test('
@@ -734,24 +734,31 @@
 (false);%0A  %7D
+, 10000
 );%0A%0A  test('
@@ -938,32 +938,39 @@
 hSnapshot();%0A  %7D
+, 10000
 );%0A%0A  test('rend
@@ -1243,16 +1243,23 @@
 t();%0A  %7D
+, 10000
 );%0A%0A  te
@@ -1478,18 +1478,25 @@
 shot();%0A
-
   %7D
+, 10000
 );%0A%7D);%0A

increase timeout on Twig renderer test