| 1 | import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'; |
| 2 | import { tmpdir } |
| 3 | import { join } |
| 4 | import type { ConfigService |
| 5 | |
| 6 | import { mailConfigured, sendmailPath |
| 7 | |
| 8 | const config = ( |
| 9 | ({ get: ( |
| 10 | |
| 11 | describe('sendmail fallback', () |
| 12 | let dir: |
| 13 | beforeAll(() => |
| 14 | dir = mkdtempSync( |
| 15 | writeFileSync( |
| 16 | join(dir, process |
| 17 | '', |
| 18 | ); |
| 19 | }); |
| 20 | afterAll(() => |
| 21 | |
| 22 | it('finds sendmail on PATH', |
| 23 | expect(sendmailPath(config |
| 24 | join(dir, process |
| 25 | ); |
| 26 | }); |
| 27 | |
| 28 | it('prefers SENDMAIL_PATH', |
| 29 | expect( |
| 30 | sendmailPath(config({ |
| 31 | ).toBe('/opt/bin/msmtp' |
| 32 | }); |
| 33 | |
| 34 | it('treats empty relay and SMTP settings as unset', |
| 35 | expect( |
| 36 | mailConfigured(config({ |
| 37 | ).toBe(true); |
| 38 | }); |
| 39 | }); |