|
9 | 9 |
|
10 | 10 | import { assertEquals, assertThrows } from 'jsr:@std/assert'; |
11 | 11 | import { STEVE, STEVEPlugin } from '../index.ts'; |
| 12 | +import { ensureDir } from '@std/fs'; |
12 | 13 |
|
13 | 14 | class MockPlugin extends STEVEPlugin { |
14 | 15 | override PLUGIN_ID = 'MOCK_PLUGIN'; |
@@ -39,6 +40,26 @@ Deno.test('STEVE: set and get includeDirectory', async () => { |
39 | 40 | await Deno.remove(tempDir, { recursive: true }); |
40 | 41 | }); |
41 | 42 |
|
| 43 | +Deno.test('STEVE: includeDirectory handles nested files', async () => { |
| 44 | + const tempDir = await Deno.makeTempDir(); |
| 45 | + const subDir = `${tempDir}/sub`; |
| 46 | + await ensureDir(subDir); |
| 47 | + const templateFile1 = `${tempDir}/template.html`; |
| 48 | + const templateFile2 = `${subDir}/nested.html`; |
| 49 | + |
| 50 | + await Deno.writeTextFile(templateFile1, 'Root Template'); |
| 51 | + await Deno.writeTextFile(templateFile2, 'Nested Template'); |
| 52 | + |
| 53 | + STEVE.includeDirectory = tempDir; |
| 54 | + |
| 55 | + const includes = STEVE.includeDirectory; |
| 56 | + assertEquals(Object.keys(includes).length, 2); |
| 57 | + assertEquals(includes['template.html'], 'Root Template'); |
| 58 | + assertEquals(includes['sub/nested.html'], 'Nested Template'); |
| 59 | + |
| 60 | + await Deno.remove(tempDir, { recursive: true }); |
| 61 | +}); |
| 62 | + |
42 | 63 | Deno.test('STEVE: throw error when no active plugin is set', () => { |
43 | 64 | assertThrows( |
44 | 65 | () => STEVE.generate({ key: 'value' }), |
|
0 commit comments