Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test progress.total and improve docs #1061

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ Progress events for uploading (sending a request) and downloading (receiving a r
}
```

If it's not possible to retrieve the body size (can happen when streaming), `total` will be `undefined`.
If the `content-length` header is missing, `total` will be `undefined`.

```js
(async () => {
Expand Down
2 changes: 2 additions & 0 deletions test/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ test('download progress - missing total size', withServer, async (t, server, got

await got('').on('downloadProgress', (event: Progress) => events.push(event));

t.is(events[0].total, undefined);
checkEvents(t, events);
});

Expand Down Expand Up @@ -183,6 +184,7 @@ test('upload progress - stream with unknown body size', withServer, async (t, se
stream.pipeline(toReadableStream(file), request, () => {})
);

t.is(events[0].total, undefined);
checkEvents(t, events);
});

Expand Down