This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| testWidgets('should display a WordPair and update on button press', (WidgetTester tester) async { | |
| await tester.pumpWidget( | |
| ChangeNotifierProvider( | |
| create: (context) => MyAppState(), | |
| child: MaterialApp(home: MyHomePage()), | |
| ), | |
| ); | |
| // Verify initial WordPair is displayed | |
| expect(find.textContaining('_'), findsOneWidget); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String? getBigCardText(WidgetTester tester) { | |
| final bigCard = find.byType(BigCard); | |
| // Find the Text widget inside the BigCard | |
| final textWidget = find.descendant( | |
| of: bigCard, | |
| matching: find.byType(Text), | |
| ); | |
| // Get the actual text content from the rendered widget |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| testWidgets('should display “mock_first” in a big card', ( WidgetTester tester, ) async { | |
| await tester.pumpWidget( | |
| ChangeNotifierProvider<MyAppState>( | |
| create: (context) => MockAppState(), | |
| child: MaterialApp(home: MyHomePage()), | |
| ), | |
| ); | |
| expect(getBigCardText(tester), equals('mock_first')); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| testWidgets(‘should display “mock_first” text’, (WidgetTester tester) async { | |
| await tester.pumpWidget( | |
| ChangeNotifierProvider<MyAppState>( | |
| create: (context) => MockAppState(), | |
| child: MaterialApp(home: MyHomePage()), | |
| ), | |
| ); | |
| expect(find.text(‘mock_first’), findsOneWidget); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should send parsed output to the callback', async () => { | |
| queueAgentFeedResponse(fullFeedResponseWithAlt); | |
| queueAgentFeedResponse(fullFeedLastResponse); | |
| const spy = vi.fn(); | |
| await bot.run(handle, 'password', spy); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('run()', () => { | |
| it('should fire the callback on every streaming event', async () => { | |
| queueAgentFeedResponse(fullFeedResponse); | |
| queueAgentFeedResponse(fullFeedLastResponse); | |
| const spy = vi.fn(); | |
| await bot.run(handle, 'password', spy); | |
| expect(spy).toHaveBeenCalledTimes(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async streamPosts(handle: string, onUpdate: (results: any) => any) { | |
| while (true) { | |
| try { | |
| const result = await this.#agent.getAuthorFeed({ | |
| actor: handle, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should stream posts with done set to false when cursor is truthy', async () => { | |
| const spy = vi.fn(); | |
| queueAgentFeedResponse(fullFeedResponse); | |
| queueAgentFeedResponse(fullFeedResponse); | |
| queueAgentFeedResponse(fullFeedLastResponse); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('checkSinglePost()', () => { | |
| it('should return the error message if fetch post failed', async () => { | |
| resetAtpAgentMock(); | |
| const postUri = 'postUri'; | |
| const bot = new AltTextBot(); | |
| const error = { message: 'error' }; | |
| mockAtpAgent.getPost.mockRejectedValue(error); | |
| const result = await bot.checkSinglePost(postUri); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { AltTextBot } from './find-altless-posts.js'; | |
| let mockAtpAgent; | |
| const resolvedHandle = { | |
| did: 'handle-did' | |
| }; | |
| const resetAtpAgentMock = () => { | |
| mockAtpAgent = { |
NewerOlder