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

Allow loaded progress of 0 in unit tests. #9956

Merged
merged 1 commit into from
Aug 3, 2018
Merged
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 test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('api', function() {
loadingTask.promise
];
Promise.all(promises).then(function (data) {
expect((data[0].loaded / data[0].total) > 0).toEqual(true);
expect((data[0].loaded / data[0].total) >= 0).toEqual(true);
Copy link
Contributor

@timvandermeij timvandermeij Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the following work too? Doing it like this would assert that the file is loaded (i.e., the total attribute is nonzero) while also asserting and explaining why the loaded attribute is zero.

// The `loaded` attribute represents the number of fetched full chunks. The
// received data is less than the size of a full chunk, so it is always zero.
expect(data[0].loaded).toEqual(0);
expect(data[0].total).toBeGreaterThan(0);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not expected that loaded is ever zero normally, it's probably just a timing related artifact on e.g. newer Node.js versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I guess I'm just overthinking this.

expect(data[1] instanceof PDFDocumentProxy).toEqual(true);
expect(loadingTask).toEqual(data[1].loadingTask);
loadingTask.destroy().then(done);
Expand Down