Pdf-lib: Error: Unit Testing failed

Created on 20 Nov 2019  ·  6Comments  ·  Source: Hopding/pdf-lib

Hi, i want contributing a little in this amazing project, but unit testing no passed 100%

  • OS: Win10 x64
  • Node.js: v10.16.3
  • Yarn: 1.19.1
  • Git: git version 2.22.0.windows.1

Test Suites: 5 failed, 42 passed, 47 total
Tests: 13 failed, 412 passed, 425 total
Snapshots: 0 total
Time: 108.816s
Ran all test suites.

Output:

  15 |       const stream = new FlateStream(new Stream(encoded));
  16 | 
> 17 |       expect(stream.decode()).toEqual(decoded);
     |                               ^
  18 |     });
  19 |   });
  20 | });

  at Object.<anonymous> (tests/core/streams/FlateStream.spec.ts:17:31)

● FlateStream › can decode flate encoded data (4)

expect(received).toEqual(expected) // deep equality

]

  15 |       const stream = new FlateStream(new Stream(encoded));
  16 | 
> 17 |       expect(stream.decode()).toEqual(decoded);
     |                               ^
  18 |     });
  19 |   });
  20 | });

  at Object.<anonymous> (tests/core/streams/FlateStream.spec.ts:17:31)

FAIL tests/core/streams/AsciiHexStream.spec.ts
● AsciiHexStream › can decode ascii hex encoded data (2)

expect(received).toEqual(expected) // deep equality

On the other hand, for now adding QR code support just like pdfmake, with pdf-lib they have a very high quality! I would like to add linear gradient, what do you think?
thanks

Most helpful comment

@punisher97 It's likely that the stream text fixture line endings are being converted to Windows line endings during cloning. You might give this a shot.
git config --global core.autocrlf false.

All 6 comments

@punisher97 It's likely that the stream text fixture line endings are being converted to Windows line endings during cloning. You might give this a shot.
git config --global core.autocrlf false.

@cshenks Thanks i will try

@punisher97 Please let me know if @cshenks's suggestion fixes the issue for you. If it does, I'd like to document this in the CONTRIBUTING.md.

@punisher97 I'm glad you're interested in contributing to pdf-lib! However, I'm afraid I do not fully understand what you mean by the following:

On the other hand, for now adding QR code support just like pdfmake, with pdf-lib they have a very high quality! I would like to add linear gradient, what do you think?

Can you clarify what you're asking here?

@punisher97 Please let me know if @cshenks's suggestion fixes the issue for you. If it does, I'd like to document this in the CONTRIBUTING.md.

Hi, it's working! thanks @cshenks I don't know the end of line generated problems also in cloning.

@punisher97 I'm glad you're interested in contributing to pdf-lib! However, I'm afraid I do not fully understand what you mean by the following:

On the other hand, for now adding QR code support just like pdfmake, with pdf-lib they have a very high quality! I would like to add linear gradient, what do you think?

Can you clarify what you're asking here?

@Hopding I'm sorry for my bad English, I mean that qrcode development based on pdfmake

Code:

Example create QRCode with drawRectangle

const qrEnc = require("./qrEnc");
...
  const qr = qrEnc.measure({
    qr: "www.google.com/",
    mode: "octet",
    eccLevel: "L",
    fit: 80,
    background: rgb(0.5, 0, 0)
  });
  console.timeEnd("QR Code");
  console.time("draw");
  for (const { x, y, ...rectOptions } of qr._canvas) {
    page.moveTo(x + pageWidth - 100, pageHeight - y - 39);
    page.drawRectangle(rectOptions);
  }
  console.timeEnd("draw");

  fs.writeFileSync(outFileName, await pdfDoc.save());

Port qrEnc.js

qrEnc.js copy from pdfmake source code

Was this page helpful?
0 / 5 - 0 ratings