diff --git a/AGENTS.md b/AGENTS.md index 43cc0e4..e4da980 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,7 +29,7 @@ npm run smoke # load the ESM, CJS, and IIFE builds; requires dist/ npm run check # format, lint, typecheck, build, test, smoke, publint ``` -Node.js **24+**. Run `npm run check` before handing work back. Run `npm run test:coverage` when you add or change an executable `src/` file. `src/index.ts`, `src/runtime/types.ts`, and `src/templates/email/types.ts` are excluded: v8 reports 0% on files with no runtime code. +Node.js **24+**. Run `npm run check` before handing work back. Run `npm run test:coverage` when you add or change an executable `src/` file. `src/index.ts`, `src/runtime/types.ts`, `src/templates/email/types.ts`, and `src/templates/document/index.ts` are excluded: v8 reports 0% on files with no runtime code. ESLint and Prettier both run in CI. Tests are Vitest, not Jest. `markup-generator` is a devDependency used to write rendered HTML in `test/write.test.ts` and `npm run generate`. It is not a runtime dependency. diff --git a/test/email.test.ts b/test/email.test.ts index 5ca472d..449ff59 100644 --- a/test/email.test.ts +++ b/test/email.test.ts @@ -149,10 +149,15 @@ describe('renderEmail', () => { bodyAttributes: 'style="margin:0"', }, }); - const html = renderEmail(template, { title: 'Hi', bodyAttributes: 'style="padding:0"' }).html; - expect(html).toMatch(/^'); - expect(html).not.toContain('lang='); + const html = renderEmail(template, { + title: 'Hi', + doctype: '', + lang: 'fr', + htmlAttributes: 'class="override"', + bodyAttributes: 'style="padding:0"', + }).html; + expect(html).toMatch(/^/); + expect(html).toContain(''); expect(html).toContain(''); }); diff --git a/test/index.test.ts b/test/index.test.ts index 218147f..5d6dbaa 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -97,12 +97,13 @@ describe('document', () => { it('accepts structured attributes on html and body', () => { const html = document({ lang: false, - htmlAttributes: { xmlns: 'http://www.w3.org/1999/xhtml', class: 'email' }, - bodyAttributes: { style: 'margin:0', 'data-theme': 'light' }, + htmlAttributes: { xmlns: 'http://www.w3.org/1999/xhtml', class: 'email', hidden: true }, + bodyAttributes: { style: 'margin:0', 'data-theme': 'light', disabled: false }, mainHtml: '

Hi

', }); - expect(html).toContain(''); + expect(html).toContain(''); expect(html).toContain(''); + expect(html).not.toContain('disabled'); }); it('supports body attributes and omitting lang (good-news style)', () => { diff --git a/vitest.config.ts b/vitest.config.ts index 6b26b4d..414a8b3 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -9,7 +9,12 @@ export default defineConfig({ provider: 'v8', reporter: ['text', 'html'], include: ['src/**/*.ts'], - exclude: ['src/index.ts', 'src/runtime/types.ts', 'src/templates/email/types.ts'], + exclude: [ + 'src/index.ts', + 'src/runtime/types.ts', + 'src/templates/email/types.ts', + 'src/templates/document/index.ts', + ], thresholds: { statements: 100, branches: 100,