Skip to content

Commit

Permalink
Improve some test descriptions and add a comment
Browse files Browse the repository at this point in the history
 - Clarify what a "non-file URL" means and add an additional test case
   for HTTPS URLs
 - Add a comment to clarify the precedence order of titles. The tests
   could more directly check that the expected precedence order is
   respected, but the logic here is expected to change very soon, so
   just add a comment for now.
  • Loading branch information
robertknight committed May 11, 2021
1 parent ab997a8 commit b06e863
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/annotator/integrations/test/pdf-metadata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ describe('PDFMetadata', function () {
}

describe('#getUri', () => {
it('returns the non-file URI', async () => {
const { pdfMetadata } = createPDFMetadata();
const uri = await pdfMetadata.getUri();
assert.equal(uri, 'http://fake.com/');
['http://fake.com/', 'https://example.com/test.pdf'].forEach(pdfURL => {
it('returns the PDF URL if it is an HTTP(S) URL', async () => {
const { pdfMetadata } = createPDFMetadata({ url: pdfURL });
const uri = await pdfMetadata.getUri();
assert.equal(uri, pdfURL);
});
});

it('returns the fingerprint as a URN when the PDF URL is a local file', async () => {
it('returns the fingerprint as a URN when the PDF URL is a file:// URL', async () => {
const { pdfMetadata } = createPDFMetadata({
url: 'file:///test.pdf',
fingerprint: 'fakeFingerprint',
Expand Down Expand Up @@ -295,6 +297,13 @@ describe('PDFMetadata', function () {
assert.isUndefined(fileLink);
});

// In order, the title is obtained from:
// 1. The `dc:title` field
// 2. The `documentInfo.Title` field
// 3. The `title` property of the HTML `document` (which PDF.js in turn
// initializes based on the filename from the `Content-Disposition` header
// or URL if that is not available)

it('gets the title from the dc:title field', async () => {
const { pdfMetadata } = createPDFMetadata();
const metadata = await pdfMetadata.getMetadata();
Expand Down

0 comments on commit b06e863

Please sign in to comment.