Skip to content

Commit

Permalink
chore: clean up smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Jul 4, 2024
1 parent 76053d2 commit 1cdac08
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion apps/preview/app/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const gather = async () => {
const absHtmlPath = `${path
.replace(relativePath, absBuildPath)
.replace(/\.(jsx|tsx)$/, '')}.html`;
const templateName = templateNameMap[absHtmlPath];
const templateName = templateNameMap[absHtmlPath] || basePath.split('/').at(-1);
return {
...acc,
[path]: {
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/fixtures/components/test-body.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Body, Text } from 'jsx-email';

// eslint-disable-next-line arrow-body-style
export const TestBody = () => {
export const Template = () => {
return (
<Body>
<Text>paths import</Text>
Expand Down
5 changes: 1 addition & 4 deletions test/smoke/fixtures/templates/code.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Body, Code, Container, Head, Html, Tailwind } from 'jsx-email';

export const CodeEmail = () => (
export const Template = () => (
<Html>
<Head />
<Tailwind>
Expand All @@ -22,6 +22,3 @@ export const CodeEmail = () => (
</Tailwind>
</Html>
);

// eslint-disable-next-line
export default CodeEmail;
2 changes: 1 addition & 1 deletion test/smoke/fixtures/templates/context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, useContext, Body, Html } from 'jsx-email';

export const TemplateName = 'local-assets';
export const templateName = 'context';

const context = createContext(123);

Expand Down
2 changes: 1 addition & 1 deletion test/smoke/fixtures/templates/default-export-props-fn.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Body, Html } from 'jsx-email';

export const TemplateName = 'default-export-props-fn';
export const templateName = 'default-export-props-fn';

export const Template = ({ test }: { test: string }) => (
<Html>
Expand Down
14 changes: 0 additions & 14 deletions test/smoke/fixtures/templates/default-export.tsx

This file was deleted.

1 change: 0 additions & 1 deletion test/smoke/fixtures/templates/empty.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion test/smoke/fixtures/templates/issue-174.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const preset = definePreset(() => {
};
});

export const TemplateName = 'Issue174';
export const templateName = 'Issue174';

export const Template = () => (
<Tailwind config={{ presets: [preset] }}>
Expand Down
10 changes: 8 additions & 2 deletions test/smoke/fixtures/templates/local-assets.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Body, Html, Img, Link } from 'jsx-email';

export const TemplateName = 'local-assets';
export const templateName = 'local-assets';

// Note: This worked while we were rendering within vite. As of v2, we're pre-rendering
// with esbuild. esbuild creates cjs bundles, which doesn't work with import.meta.
// Additionally, import.meta.resolve doesn't work with the esbuild pre-render because
// the filesystem location is in a temp directory, so the resolve is always incorrect.
// This is a step back but we can try and figure out a good solution later.
// @ts-ignore
const baseUrl = import.meta.resolve('../static/');
// const baseUrl = import.meta.resolve('../static/');
const baseUrl = '../static';

export const Template = () => {
const catUrl = `${baseUrl}cat.jpeg`;
Expand Down
4 changes: 2 additions & 2 deletions test/smoke/fixtures/templates/paths.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Html } from 'jsx-email';

import { TestBody } from '@components/test-body';
import { Template as TestBody } from '@components/test-body';

export const TemplateName = 'local-assets';
export const templateName = 'paths';

// eslint-disable-next-line arrow-body-style
export const Template = () => {
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/fixtures/templates/props/preview-props-fn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export const Template = ({ test }: { test: string }) => (
</Html>
);

Template.PreviewProps = () => {
export const previewProps = () => {
return { test: 'batman' };
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Body, Html } from 'jsx-email';

export const TemplateName = 'preview-props';
export const TemplateName = 'preview-props-named';

export const Template = ({ test }: { test: string }) => (
<Html>
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/fixtures/templates/props/preview-props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const Template = ({ test }: { test: string }) => (
</Html>
);

Template.PreviewProps = { test: 'batman' };
export const previewProps = { test: 'batman' };

0 comments on commit 1cdac08

Please sign in to comment.