Forked from graphicbeacon/hacker_news_scraper_test.dart
Created
February 27, 2020 20:17
-
-
Save zombiemachines/f3918c6f50f8c6403265b6a909e9ed3d to your computer and use it in GitHub Desktop.
Code snipper for "Write your first Web Scraper in Dart" Medium post
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
| void main() { | |
| MockClient client = null; | |
| test('calling initiate(client) returns a list of storylinks', () async { | |
| // Arrange | |
| client = MockClient((req) => Future(() => Response(''' | |
| <body> | |
| <table><tbody><tr> | |
| <td class="title"> | |
| <a class="storylink" href="https://dartlang.org">Get started with Dart</a> | |
| </td> | |
| </tr></tbody></table> | |
| </body> | |
| ''', 200))); | |
| // Act | |
| var response = await hacker_news_scraper.initiate(client); | |
| // Assert | |
| expect( | |
| response, | |
| equals(json.encode([ | |
| { | |
| 'title': 'Get started with Dart', | |
| 'href': 'https://dartlang.org', | |
| } | |
| ]))); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment