cmd-johnson / deno-oauth2-client

Minimalistic OAuth 2.0 client for Deno.
MIT License
47 stars 9 forks source link

Add Tests #3

Closed cmd-johnson closed 4 years ago

cmd-johnson commented 4 years ago

Adds tests and bumps the code coverage up to 100%.

deno test --coverage --unstable still reports three untested lines, but that appears to be a bug in either the coverage reporter or the sourcemap generator, as those lines cannot not be covered:

  40 |         if (params.has("error")) {
 101 |         if (!response.ok) {
 122 |         if (body.refresh_token !== undefined &&

First, those lines are completely off. The actual contents of those lines are:

  40 |     if (typeof this.client.config.redirectUri === "string") {
 101 |       throw new TypeError("Missing code, unable to request token");
 122 |
 ^^^ line 122 is literally empty

The lines of the reported snippets are actually on lines 95, 169 and the third one does not even exist like this in the code, as it is actually split over a few lines:

 203 |     if (
 204 |       body.refresh_token !== undefined &&
 205 |       typeof body.refresh_token !== "string"
 206 |     ) {

Anyway, when modifying any of those statement's control flows, tests fail, so I can assume those lines are actually relevant and covered by the tests failing in those scenarios.

Close #1