-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(repo): add additional tests for config loading from parent dire…
…ctories, and picking up disableDefaultStyle in render from config
- Loading branch information
1 parent
f28048c
commit c6f4c2e
Showing
8 changed files
with
148 additions
and
14 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
packages/jsx-email/test/config/load/dotdir/.snapshots/load-mjs.test.ts.snap
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
packages/jsx-email/test/config/load/parent-dir/child-dir/.snapshots/parent-dir.test.ts.snap
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,93 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`loadConfig → parent dir > loadConfig 1`] = ` | ||
{ | ||
"logLevel": "info", | ||
"plugins": [ | ||
{ | ||
"log": LogLevel { | ||
"currentLevel": 2, | ||
"debug": [Function], | ||
"error": [Function], | ||
"info": [Function], | ||
"log": [Function], | ||
"methodFactory": LogFactory { | ||
"options": { | ||
"level": [Function], | ||
"name": [Function], | ||
"ready": { | ||
"promise": Promise {}, | ||
"reject": [Function], | ||
"resolve": [Function], | ||
}, | ||
"template": "[{{time}}] [34mjsx-email[39m [1m∵ root/minify[22m {{level}} ", | ||
"time": [Function], | ||
}, | ||
"ready": { | ||
"promise": Promise {}, | ||
"reject": [Function], | ||
"resolve": [Function], | ||
}, | ||
Symbol(log-instance): [Circular], | ||
Symbol(log-levels): { | ||
"DEBUG": 1, | ||
"ERROR": 4, | ||
"INFO": 2, | ||
"SILENT": 5, | ||
"TRACE": 0, | ||
"WARN": 3, | ||
}, | ||
}, | ||
"name": "dot-log:[1m∵ root/minify[22m", | ||
"options": { | ||
"factory": LogFactory { | ||
"options": { | ||
"level": [Function], | ||
"name": [Function], | ||
"ready": { | ||
"promise": Promise {}, | ||
"reject": [Function], | ||
"resolve": [Function], | ||
}, | ||
"template": "[{{time}}] [34mjsx-email[39m [1m∵ root/minify[22m {{level}} ", | ||
"time": [Function], | ||
}, | ||
"ready": { | ||
"promise": Promise {}, | ||
"reject": [Function], | ||
"resolve": [Function], | ||
}, | ||
Symbol(log-instance): [Circular], | ||
Symbol(log-levels): { | ||
"DEBUG": 1, | ||
"ERROR": 4, | ||
"INFO": 2, | ||
"SILENT": 5, | ||
"TRACE": 0, | ||
"WARN": 3, | ||
}, | ||
}, | ||
"id": "dot-log:[1m∵ root/minify[22m", | ||
"level": "info", | ||
"name": "dot-log:[1m∵ root/minify[22m", | ||
"prefix": undefined, | ||
}, | ||
"trace": [Function], | ||
"type": "LogLevel", | ||
"warn": [Function], | ||
}, | ||
"name": "root/minify", | ||
"process": [Function], | ||
"symbol": Symbol(jsx-email/plugin), | ||
}, | ||
], | ||
"render": { | ||
"disableDefaultStyle": true, | ||
"inlineCss": false, | ||
"minify": true, | ||
"plainText": false, | ||
"pretty": false, | ||
}, | ||
"symbol": Symbol(jsx-email/config), | ||
} | ||
`; |
9 changes: 9 additions & 0 deletions
9
packages/jsx-email/test/config/load/parent-dir/child-dir/parent-dir.test.ts
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,9 @@ | ||
import { loadConfig } from '../../../../../src/config.js'; | ||
|
||
describe('loadConfig → parent dir', async () => { | ||
test('loadConfig', async () => { | ||
const config = await loadConfig(__dirname); | ||
expect(config).toBeDefined(); | ||
expect(config).toMatchSnapshot(); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/jsx-email/test/config/load/parent-dir/jsx-email.config.mjs
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,5 @@ | ||
import { defineConfig } from 'jsx-email/config'; | ||
|
||
export const config = defineConfig({ | ||
render: { disableDefaultStyle: true, minify: true } | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/jsx-email/test/config/render/.snapshots/config-render.test.tsx.snap
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,10 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`config → render > render disableDefaultStyle from config 1`] = ` | ||
"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"> | ||
<html> | ||
<body><a href=\\"https://bat.man\\" style></a></body> | ||
</html>" | ||
`; |
17 changes: 17 additions & 0 deletions
17
packages/jsx-email/test/config/render/config-render.test.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,17 @@ | ||
import React from 'react'; | ||
|
||
import { loadConfig } from '../../../src/config.js'; | ||
import { render } from '../../../src/renderer/render.js'; | ||
import { Template } from '../../render/fixtures/components.js'; | ||
|
||
// process.chdir(__dirname); | ||
|
||
describe('config → render', async () => { | ||
test('render disableDefaultStyle from config', async () => { | ||
// Note: load the config from the target directory first, so it'll be picked up on cache | ||
// vitest makes it hard to change the workding directory due to workers use | ||
await loadConfig(__dirname); | ||
const result = await render(<Template />); | ||
expect(result).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig } from 'jsx-email/config'; | ||
|
||
export const config = defineConfig({ | ||
render: { disableDefaultStyle: true, minify: false, pretty: true } | ||
}); |
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,9 @@ | ||
import React from 'react'; | ||
|
||
import { Link } from '../../../dist/esm'; | ||
|
||
export const Template: React.FC = () => ( | ||
<> | ||
<Link href="https://bat.man" /> | ||
</> | ||
); |