import { pretty, render } from '@react-email/render';
import { ResponsiveColumn, ResponsiveRow } from '@responsive-email/react-email';
import React from 'react';
import plugin from 'tailwindcss/plugin';
import { Body } from '../body/index.js';
import { Button } from '../button/index.js';
import { Column } from '../column/index.js';
import { Head } from '../head/index.js';
import { Heading } from '../heading/index.js';
import { Hr } from '../hr/index.js';
import { Html } from '../html/index.js';
import { Link } from '../link/index.js';
import { Row } from '../row/index.js';
import { Section } from '../section/index.js';
import type { TailwindConfig } from './tailwind.js';
import { Tailwind } from './tailwind.js';
describe('Tailwind component', () => {
const headMissingError =
'Tailwind:
not found inside .\nMove inside , or remove these classes that require a :';
it('allows for complex children manipulation', async () => {
const actualOutput = await render(
This is the first columnThis is the second column,
);
expect(actualOutput).toMatchInlineSnapshot(
`"
"
`);
});
it('resolves variables nested inside the definitions of other variables', async () => {
const html = await render(
default shadow color
,
);
expect(html).not.toContain('var(');
expect(html).toContain('0 4px 6px -1px rgb(0,0,0,0.1)');
expect(html).toContain('currentcolor');
});
it("uses each element's default shadow and ring colors independently", async () => {
const html = await render(
card
button
,
);
expect(html).not.toContain('var(');
expect(html).toContain('0 4px 6px -1px rgb(0,0,0,0.1)');
expect(html).toContain('currentcolor');
});
it('preserves local colors without changing a sibling with the same utilities', async () => {
const html = await render(
colored
default
,
);
const document = new DOMParser().parseFromString(html, 'text/html');
const [colored, defaultElement] = document.querySelectorAll('div');
expect(html).not.toContain('var(');
expect(colored?.style.boxShadow).toContain('rgb(255,0,0');
expect(colored?.style.boxShadow).toContain('rgb(0,0,255');
expect(defaultElement?.style.boxShadow).toContain('rgb(0,0,0,0.1)');
expect(defaultElement?.style.boxShadow).toContain('currentcolor');
expect(defaultElement?.style.boxShadow).not.toContain('rgb(255,0,0');
});
it('does not use hover shadow colors for the inline default', async () => {
const html = await render(
card
,
);
expect(html).not.toContain('var(');
expect(html).toContain('0 4px 6px -1px rgb(0,0,0,0.1)');
expect(html).toContain('hover_shadow-red-500');
});
it('works with class manipulation done on components', async () => {
const MyComponnt = (props: {
className?: string;
style?: React.CSSProperties;
}) => {
expect(
props.style,
'styles should not be generated for a component',
).toBeUndefined();
expect(props.className).toBe('p-4 text-blue-400');
return (
);
};
expect(
await render(
,
),
).toMatchInlineSnapshot(
`""`,
);
});
it("works properly with 'no-underline'", async () => {
const actualOutput = await render(
or copy and paste this URL into your browser:{' '}
https://react.email
or copy and paste this URL into your browser:{' '}
https://react.email