@@ -19,13 +19,22 @@ const mockedExeca = execa as jest.MockedFunction<typeof execa>
1919mockedExeca . mockImplementation ( ( ) => {
2020 const result = {
2121 stdout :
22- '<svg viewBox="0 0 1024 768"><rect fill="#bada5500"/><g></g></rect></svg>'
22+ '<svg viewBox="0 0 1024 768"><rect width="100%" height="100%" fill="#bada5500"/><g><path fill="#fff" d="M300,188 L0,188 L174,146 L300,188"/ ></g></rect></svg>'
2323 } as unknown as ExecaChildProcess < Buffer >
2424 return result
2525} )
2626
2727const mockedFsAccess = fs . access as jest . MockedFunction < typeof fs . access >
2828
29+ const mockedFsReadFile = fs . readFile as jest . MockedFunction < typeof fs . readFile >
30+ mockedFsReadFile . mockImplementation ( ( ) =>
31+ Promise . resolve (
32+ Buffer . from (
33+ '<svg viewBox="0 0 1024 768"><rect width="100%" height="100%" fill="#bada5500"/><g><path fill="#fff" d="M300,188 L0,188 L174,146 L300,188"/></g></rect></svg>'
34+ )
35+ )
36+ )
37+
2938mockedFsAccess . mockImplementation ( async ( ) =>
3039 Promise . reject ( new Error ( 'Mocked: Binary not available' ) )
3140)
@@ -131,9 +140,9 @@ describe('runTriangle', () => {
131140 await trianglePlugin . apply ( fileContent , { ...mockedMetadata } )
132141 expect ( mockedExeca . mock . calls ) . toHaveLength ( 2 )
133142 expect ( mockedExeca . mock . calls [ 1 ] ) . toHaveLength ( 2 )
134- const args = mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] || [ ]
135- args [ 1 ] = " mocked"
136- args [ args . length - 1 ] = " mocked"
143+ const args = ( mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] ) || [ ]
144+ args [ 1 ] = ' mocked'
145+ args [ args . length - 1 ] = ' mocked'
137146 expect ( args ) . toMatchSnapshot ( )
138147 } )
139148
@@ -147,9 +156,9 @@ describe('runTriangle', () => {
147156 await trianglePlugin . apply ( fileContent , { ...mockedMetadata } )
148157 expect ( mockedExeca . mock . calls ) . toHaveLength ( 2 )
149158 expect ( mockedExeca . mock . calls [ 1 ] ) . toHaveLength ( 2 )
150- const args = mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] || [ ]
151- args [ 1 ] = " mocked"
152- args [ args . length - 1 ] = " mocked"
159+ const args = ( mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] ) || [ ]
160+ args [ 1 ] = ' mocked'
161+ args [ args . length - 1 ] = ' mocked'
153162 expect ( args ) . toMatchSnapshot ( )
154163 } )
155164
@@ -166,9 +175,9 @@ describe('runTriangle', () => {
166175 } )
167176 expect ( mockedExeca . mock . calls ) . toHaveLength ( 2 )
168177 expect ( mockedExeca . mock . calls [ 1 ] ) . toHaveLength ( 2 )
169- const args = mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] || [ ]
170- args [ 1 ] = " mocked"
171- args [ args . length - 1 ] = " mocked"
178+ const args = ( mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] ) || [ ]
179+ args [ 1 ] = ' mocked'
180+ args [ args . length - 1 ] = ' mocked'
172181 expect ( args ) . toMatchSnapshot ( )
173182 } )
174183
@@ -183,9 +192,9 @@ describe('runTriangle', () => {
183192 await trianglePlugin . apply ( fileContent , { ...mockedMetadata } )
184193 expect ( mockedExeca . mock . calls ) . toHaveLength ( 2 )
185194 expect ( mockedExeca . mock . calls [ 1 ] ) . toHaveLength ( 2 )
186- const args = mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] || [ ]
187- args [ 1 ] = " mocked"
188- args [ args . length - 1 ] = " mocked"
195+ const args = ( mockedExeca . mock . calls [ 1 ] [ 1 ] as string [ ] ) || [ ]
196+ args [ 1 ] = ' mocked'
197+ args [ args . length - 1 ] = ' mocked'
189198 expect ( args ) . toMatchSnapshot ( )
190199 } )
191200} )
0 commit comments