@@ -5,30 +5,22 @@ import generateBlogData from '@/next-data/generators/blogData.mjs';
55
66let files = [ ] ;
77
8- jest . mock ( 'node:fs' , ( ) => {
9- const originalFs = jest . requireActual ( 'node:fs' ) ;
10- return {
11- ...originalFs ,
12- createReadStream : jest . fn ( filename => {
13- const readable = new Readable ( ) ;
14- const file = files . find ( f => filename . endsWith ( normalize ( f . path ) ) ) ;
15- readable . push ( `---\n` ) ;
16- file . frontMatterContent . forEach ( line => readable . push ( `${ line } \n` ) ) ;
17- readable . push ( `---\n` ) ;
18- readable . push ( null ) ;
19- readable . close = ( ) => { } ;
20- return readable ;
21- } ) ,
22- } ;
23- } ) ;
24-
25- jest . mock ( '../../../next.helpers.mjs' , ( ) => {
26- const originalHelpers = jest . requireActual ( '../../../next.helpers.mjs' ) ;
27- return {
28- ...originalHelpers ,
29- getMarkdownFiles : ( ) => Promise . resolve ( files . map ( file => file . path ) ) ,
30- } ;
31- } ) ;
8+ jest . mock ( 'node:fs' , ( ) => ( {
9+ createReadStream : jest . fn ( filename => {
10+ const readable = new Readable ( ) ;
11+ const file = files . find ( f => filename . endsWith ( normalize ( f . path ) ) ) ;
12+ readable . push ( `---\n` ) ;
13+ file . frontMatterContent . forEach ( line => readable . push ( `${ line } \n` ) ) ;
14+ readable . push ( `---\n` ) ;
15+ readable . push ( null ) ;
16+ readable . close = ( ) => { } ;
17+ return readable ;
18+ } ) ,
19+ } ) ) ;
20+
21+ jest . mock ( '../../../next.helpers.mjs' , ( ) => ( {
22+ getMarkdownFiles : ( ) => Promise . resolve ( files . map ( file => file . path ) ) ,
23+ } ) ) ;
3224
3325describe ( 'generateBlogData' , ( ) => {
3426 it ( 'should return zero posts and only the default "all" category is no md file is found' , async ( ) => {
0 commit comments