@@ -218,9 +218,13 @@ describe('link', () => {
218
218
219
219
describe ( 'pull' , ( ) => {
220
220
const diagram = 'test/output/connected-diagram.mmd' ;
221
+ const diagram2 = 'test/output/connected-diagram-2.mmd' ;
221
222
222
223
beforeEach ( async ( ) => {
223
- await copyFile ( 'test/fixtures/connected-diagram.mmd' , diagram ) ;
224
+ await Promise . all ( [
225
+ copyFile ( 'test/fixtures/connected-diagram.mmd' , diagram ) ,
226
+ copyFile ( 'test/fixtures/connected-diagram.mmd' , diagram2 ) ,
227
+ ] ) ;
224
228
} ) ;
225
229
226
230
it ( 'should fail if MermaidChart document has not yet been linked' , async ( ) => {
@@ -243,7 +247,7 @@ describe('pull', () => {
243
247
) . rejects . toThrowError ( `Diagram at ${ diagram } has no code` ) ;
244
248
} ) ;
245
249
246
- it ( 'should pull document and add a `id:` field to frontmatter' , async ( ) => {
250
+ it ( 'should pull documents and add a `id:` field to frontmatter' , async ( ) => {
247
251
const { program } = mockedProgram ( ) ;
248
252
249
253
const mockedDiagram = {
@@ -255,22 +259,30 @@ title: My cool flowchart
255
259
A[I've been updated!]` ,
256
260
} ;
257
261
258
- vi . mocked ( MermaidChart . prototype . getDocument ) . mockResolvedValueOnce ( mockedDiagram ) ;
262
+ vi . mocked ( MermaidChart . prototype . getDocument ) . mockResolvedValue ( mockedDiagram ) ;
259
263
260
- await program . parseAsync ( [ '--config' , CONFIG_AUTHED , 'pull' , diagram ] , { from : 'user' } ) ;
264
+ await program . parseAsync ( [ '--config' , CONFIG_AUTHED , 'pull' , diagram , diagram2 ] , {
265
+ from : 'user' ,
266
+ } ) ;
261
267
262
- const diagramContents = await readFile ( diagram , { encoding : 'utf8' } ) ;
268
+ for ( const file of [ diagram , diagram2 ] ) {
269
+ const diagramContents = await readFile ( file , { encoding : 'utf8' } ) ;
263
270
264
- expect ( diagramContents ) . toContain ( `id: ${ mockedDiagram . documentID } ` ) ;
265
- expect ( diagramContents ) . toContain ( "flowchart TD\n A[I've been updated!]" ) ;
271
+ expect ( diagramContents ) . toContain ( `id: ${ mockedDiagram . documentID } ` ) ;
272
+ expect ( diagramContents ) . toContain ( "flowchart TD\n A[I've been updated!]" ) ;
273
+ }
266
274
} ) ;
267
275
} ) ;
268
276
269
277
describe ( 'push' , ( ) => {
270
278
const diagram = 'test/output/connected-diagram.mmd' ;
279
+ const diagram2 = 'test/output/connected-diagram-2.mmd' ;
271
280
272
281
beforeEach ( async ( ) => {
273
- await copyFile ( 'test/fixtures/connected-diagram.mmd' , diagram ) ;
282
+ await Promise . all ( [
283
+ copyFile ( 'test/fixtures/connected-diagram.mmd' , diagram ) ,
284
+ copyFile ( 'test/fixtures/connected-diagram.mmd' , diagram2 ) ,
285
+ ] ) ;
274
286
} ) ;
275
287
276
288
it ( 'should fail if MermaidChart document has not yet been linked' , async ( ) => {
@@ -283,16 +295,18 @@ describe('push', () => {
283
295
) . rejects . toThrowError ( 'Diagram at test/fixtures/unsynced.mmd has no id' ) ;
284
296
} ) ;
285
297
286
- it ( 'should push document and remove the `id:` field front frontmatter' , async ( ) => {
298
+ it ( 'should push documents and remove the `id:` field front frontmatter' , async ( ) => {
287
299
const { program } = mockedProgram ( ) ;
288
300
289
- vi . mocked ( MermaidChart . prototype . getDocument ) . mockResolvedValueOnce ( mockedEmptyDiagram ) ;
301
+ vi . mocked ( MermaidChart . prototype . getDocument ) . mockResolvedValue ( mockedEmptyDiagram ) ;
290
302
291
303
await expect ( readFile ( diagram , { encoding : 'utf8' } ) ) . resolves . not . toContain ( / ^ i d : / ) ;
292
304
293
- await program . parseAsync ( [ '--config' , CONFIG_AUTHED , 'push' , diagram ] , { from : 'user' } ) ;
305
+ await program . parseAsync ( [ '--config' , CONFIG_AUTHED , 'push' , diagram , diagram2 ] , {
306
+ from : 'user' ,
307
+ } ) ;
294
308
295
- expect ( vi . mocked ( MermaidChart . prototype . setDocument ) ) . toHaveBeenCalledOnce ( ) ;
309
+ expect ( vi . mocked ( MermaidChart . prototype . setDocument ) ) . toHaveBeenCalledTimes ( 2 ) ;
296
310
expect ( vi . mocked ( MermaidChart . prototype . setDocument ) ) . toHaveBeenCalledWith (
297
311
expect . objectContaining ( {
298
312
code : expect . not . stringContaining ( 'id:' ) ,
0 commit comments