Import Instagram archive to a Bluesky account
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use the actual uploadMediaAndEmbed method without redefining the MediaProcessResult[]

+10 -23
+10 -23
src/instagram-to-bluesky.test.ts
··· 544 544 }); 545 545 546 546 describe('uploadMediaAndEmbed', () => { 547 - // Extract the function for testing 548 - let uploadMediaAndEmbed: ( 549 - postText: string, 550 - embeddedMedia: any[], 551 - bluesky: BlueskyClient 552 - ) => Promise<{ 553 - importedMediaCount: number; 554 - uploadedMedia: any; 555 - }>; 556 - 557 - beforeAll(() => { 558 - // Get access to the inner function for testing 559 - const mainModule = require('../src/instagram-to-bluesky'); 560 - uploadMediaAndEmbed = mainModule.uploadMediaAndEmbed; 561 - }); 562 - 563 547 test('should handle multiple images correctly', async () => { 564 548 const mockBluesky = { 565 549 uploadMedia: jest.fn().mockImplementation((_, __) => ··· 571 555 ) 572 556 }; 573 557 574 - const mockImages = Array(4).fill(null).map(() => ({ 575 - getType: () => 'image', 558 + const mockImages = Array(4).fill(null).map((_, index) => ({ 559 + getType: (): "image" => "image", 576 560 mediaBuffer: Buffer.from('test'), 577 - mimeType: 'image/jpeg' 561 + mimeType: 'image/jpeg', 562 + mediaText: `Test image ${index + 1}` 578 563 })); 579 564 580 565 const result = await uploadMediaAndEmbed( ··· 607 592 }; 608 593 609 594 const mockVideo = { 610 - getType: () => 'video', 595 + getType: (): "video" => "video", 611 596 mediaBuffer: Buffer.from('test-video'), 612 597 mimeType: 'video/mp4', 613 - aspectRatio: 1.777 598 + mediaText: 'Test video', 599 + aspectRatio: { width: 1920, height: 1080 } 614 600 }; 615 601 616 602 const result = await uploadMediaAndEmbed( ··· 634 620 }; 635 621 636 622 const mockImage = { 637 - getType: () => 'image', 623 + getType: (): "image" => "image", 638 624 mediaBuffer: Buffer.from('test'), 639 - mimeType: 'image/jpeg' 625 + mimeType: 'image/jpeg', 626 + mediaText: 'Test image that will fail to upload' 640 627 }; 641 628 642 629 const result = await uploadMediaAndEmbed(