-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53387d3
commit 15e111b
Showing
6 changed files
with
181 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`create-jsx-email > command 1`] = ` | ||
" | ||
create-jsx-email v2.0.3 | ||
The fastest way to get started with JSX Email | ||
Creating Project at: .test/new/templates | ||
Creating a new template at: .test/new/templates/email.tsx | ||
✓ jsx-email Project Created | ||
Next, run: | ||
$ cd email-project | ||
$ yarn | ||
$ yarn dev | ||
Check out the docs! http://jsx.email/docs/quick-start | ||
" | ||
`; | ||
|
||
exports[`create-jsx-email > command 2`] = ` | ||
"import { | ||
Body, | ||
Button, | ||
Container, | ||
Head, | ||
Hr, | ||
Html, | ||
Link, | ||
Preview, | ||
Section, | ||
Text | ||
} from 'jsx-email'; | ||
interface TemplateProps { | ||
email: string; | ||
name: string; | ||
} | ||
const main = { | ||
backgroundColor: '#f6f9fc', | ||
fontFamily: | ||
'-apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,\\"Helvetica Neue\\",Ubuntu,sans-serif' | ||
}; | ||
const container = { | ||
backgroundColor: '#ffffff', | ||
margin: '0 auto', | ||
marginBottom: '64px', | ||
padding: '20px 0 48px' | ||
}; | ||
const box = { | ||
padding: '0 48px' | ||
}; | ||
const hr = { | ||
borderColor: '#e6ebf1', | ||
margin: '20px 0' | ||
}; | ||
const paragraph = { | ||
color: '#777', | ||
fontSize: '16px', | ||
lineHeight: '24px', | ||
textAlign: 'left' as const | ||
}; | ||
const anchor = { | ||
color: '#777' | ||
}; | ||
const button = { | ||
fontWeight: 'bold', | ||
padding: '10px', | ||
textDecoration: 'none' | ||
}; | ||
export const previewProps = { | ||
email: '[email protected]', | ||
name: 'Bruce Wayne' | ||
}; | ||
export const templateName = 'email-project'; | ||
export const Template = ({ email, name }: TemplateProps) => ( | ||
<Html> | ||
<Head /> | ||
<Preview>This is our email preview text for {name} <{email}></Preview> | ||
<Body style={main}> | ||
<Container style={container}> | ||
<Section style={box}> | ||
<Text style={paragraph}>This is our email body text</Text> | ||
<Button | ||
align={'center'} | ||
backgroundColor={'#777'} | ||
borderRadius={5} | ||
fontSize={16} | ||
height={60} | ||
href=\\"https://example.com\\" | ||
style={button} | ||
textColor={'#fff'} | ||
width={160} | ||
> | ||
Action Button | ||
</Button> | ||
<Hr style={hr} /> | ||
<Text style={paragraph}> | ||
This is text content with a{' '} | ||
<Link style={anchor} href=\\"mailto:{email}\\"> | ||
link | ||
</Link> | ||
. | ||
</Text> | ||
</Section> | ||
</Container> | ||
</Body> | ||
</Html> | ||
); | ||
" | ||
`; | ||
exports[`create-jsx-email > command 3`] = ` | ||
[ | ||
".test/new/README.md", | ||
".test/new/package.json", | ||
".test/new/tsconfig.json", | ||
".test/new/templates/email.tsx", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { readFile } from 'node:fs/promises'; | ||
import { join } from 'node:path'; | ||
|
||
import { execa } from 'execa'; | ||
import { globby } from 'globby'; | ||
import strip from 'strip-ansi'; | ||
|
||
process.chdir(__dirname); | ||
|
||
describe('create-jsx-email', async () => { | ||
test('command', async () => { | ||
const { stdout } = await execa({ | ||
cwd: __dirname, | ||
shell: true | ||
// Note: For some reason `pnpm exec` is fucking with our CWD, and resets it to | ||
// packages/jsx-email, which causes the config not to be found. so we use npx instead | ||
})`pnpm exec create-jsx-email .test/new --yes`; | ||
const plain = strip(stdout); | ||
|
||
expect(plain).toMatchSnapshot(); | ||
|
||
const contents = await readFile(join(__dirname, '.test/new/templates/email.tsx'), 'utf8'); | ||
expect(contents).toMatchSnapshot(); | ||
|
||
const files = await globby('.test/new/**/*'); | ||
expect(files).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters