1+ import type { FileSystem } from '@ingenyus/swarm' ;
12import { beforeEach , describe , expect , it , vi } from 'vitest' ;
23import { TemplateUtility } from './templates' ;
34
@@ -21,15 +22,7 @@ vi.mock('./strings', () => ({
2122
2223describe ( 'TemplateUtility' , ( ) => {
2324 let templateUtility : TemplateUtility ;
24- let mockFileSystem : {
25- existsSync : ReturnType < typeof vi . fn > ;
26- readFileSync : ReturnType < typeof vi . fn > ;
27- writeFileSync : ReturnType < typeof vi . fn > ;
28- mkdirSync : ReturnType < typeof vi . fn > ;
29- copyFileSync : ReturnType < typeof vi . fn > ;
30- readdirSync : ReturnType < typeof vi . fn > ;
31- statSync : ReturnType < typeof vi . fn > ;
32- } ;
25+ let mockFileSystem : FileSystem ;
3326
3427 beforeEach ( ( ) => {
3528 mockFileSystem = {
@@ -40,25 +33,27 @@ describe('TemplateUtility', () => {
4033 copyFileSync : vi . fn ( ) ,
4134 readdirSync : vi . fn ( ) ,
4235 statSync : vi . fn ( ) ,
43- } ;
36+ } as FileSystem ;
4437 templateUtility = new TemplateUtility ( mockFileSystem ) ;
4538 } ) ;
4639
4740 describe ( 'processTemplate' , ( ) => {
4841 beforeEach ( ( ) => {
4942 // Mock the file system to simulate template files
50- mockFileSystem . existsSync = vi . fn ( ) . mockImplementation ( ( path : string ) => {
51- // Return false for test templates to force renderString usage
52- return (
53- ! path . includes ( 'test-template' ) &&
54- ! path . includes ( 'multi-template' ) &&
55- ! path . includes ( 'repeat-template' ) &&
56- ! path . includes ( 'empty-template' ) &&
57- ! path . includes ( 'no-placeholders' )
58- ) ;
59- } ) ;
43+ ( mockFileSystem . existsSync as ReturnType < typeof vi . fn > ) = vi
44+ . fn ( )
45+ . mockImplementation ( ( path : string ) => {
46+ // Return false for test templates to force renderString usage
47+ return (
48+ ! path . includes ( 'test-template' ) &&
49+ ! path . includes ( 'multi-template' ) &&
50+ ! path . includes ( 'repeat-template' ) &&
51+ ! path . includes ( 'empty-template' ) &&
52+ ! path . includes ( 'no-placeholders' )
53+ ) ;
54+ } ) ;
6055
61- mockFileSystem . readFileSync = vi
56+ ( mockFileSystem . readFileSync as ReturnType < typeof vi . fn > ) = vi
6257 . fn ( )
6358 . mockImplementation ( ( path : string ) => {
6459 if ( path . includes ( 'test-template.eta' ) ) {
0 commit comments