title: How can we do unit testing asynchronous functions using test package in angulardart?
body: <p>I tried creating async function using angulardart code which will call internal service and from service will return response from a test url. How will i mock the particular function getUserDetails().</p>
  
  <p><strong>login_component.html</strong></p>
  
  <pre><code>&lt;div class="container"&gt;
     &lt;button type="button" (click)="getUserDetails()"&gt;Click me to see 
       details
     &lt;/button&gt;
  &lt;/div&gt;
  &lt;div *ngFor="let user of userDetails"&gt;{{user.id}}&lt;/div&gt;
  </code></pre>
  
  <p><strong>login_component.dart:</strong></p>
  
  <pre><code>Future&lt;Null&gt; getUserDetails() async {
   try {
     userDetails = await _loginService.userDetails();
     print(userDetails);
   } catch (e) {
     errMsg = e.toString();
   }
  }
  </code></pre>
  
  <p><strong>login_service.dart:</strong></p>
  
  <pre><code>Future&lt;dynamic&gt; userDetails() async {
      var _url = 'https://jsonplaceholder.typicode.com/users';
      try {
        var res = await _http.get(_url);
        var response = _extractData(res).map((value) =&gt; new 
        List.fromJson(value)).toList();
        return response;
         } catch (e) {
           print(e);
          }
  }
  dynamic _extractData(Response resp) =&gt; JSON.decode(resp.body);
  </code></pre>
  
  <p><strong>list.dart</strong></p>
  
  <pre><code>class List {
    int id;
    String name;
    List(this.id, this.name);
    factory List.fromJson(Map&lt;dynamic, dynamic&gt; list) =&gt;
    new List(list['id'], list['name']);
    Map toJson() =&gt; {'id': id, 'name': name};
  }
  </code></pre>
  
  <p>Please help me in finding out solution. Also how can i check the test code coverage in angulardart ?</p>