Updated tests and barcode example to latest changes

This commit is contained in:
Alexander Cerutti
2019-06-30 02:01:17 +02:00
parent a5ac1e13a4
commit 25aa60ba99
2 changed files with 89 additions and 120 deletions

View File

@@ -29,19 +29,16 @@ app.all(async function manageRequest(request, response) {
overrides: request.body || request.params || request.query,
});
let bc: PassWithBarcodeMethods;
if (request.query.alt === true) {
// After this, pass.props["barcodes"] will have support for all the formats
// while pass.props["barcode"] will be the first of barcodes.
bc = pass.barcode("Thank you for using this package <3") as PassWithBarcodeMethods
pass.barcodes("Thank you for using this package <3");
} else {
// After this, pass.props["barcodes"] will have support for just two of three
// of the passed format (the valid ones) and pass.props["barcode"] the first of barcodes.
// if not specified, altText is automatically the message
// of the passed format (the valid ones);
bc = pass.barcode({
pass.barcodes({
message: "Thank you for using this package <3",
format: "PKBarcodeFormatCode128"
}, {
@@ -50,29 +47,17 @@ app.all(async function manageRequest(request, response) {
}, {
message: "Thank you for using this package <3",
format: "PKBarcodeFormatMock44617"
}) as PassWithBarcodeMethods;
});
}
// You can change the format chosen for barcode prop support by calling .backward()
// or cancel the support by calling empty .backward
// like bc.backward().
// If the property passed does not exists, things does not change.
// You can change the format chosen for barcode prop support by calling .barcode()
// or cancel the support by calling empty .barcode
// like pass.barcode().
bc.backward("PKBarcodeFormatPDF417");
pass.barcode("PKBarcodeFormatPDF417");
// If your barcode structures got not autogenerated yet (as happens with string
// parameter of barcode) you can call .autocomplete() to generate the support
// to all the structures. Please beware that this will overwrite ONLY barcodes and not barcode.
if (!request.query.alt) {
// String generated barcode returns autocomplete as empty function
bc.autocomplete();
}
// @ts-ignore - ignoring for logging purposes
console.log("Barcode property is now:", pass._props["barcode"]);
// @ts-ignore - ignoring for logging purposes
console.log("Barcodes support is autocompleted:", pass._props["barcodes"]);
console.log("Barcode property is now:", pass.props["barcode"]);
console.log("Barcodes support is autocompleted:", pass.props["barcodes"]);
const stream = pass.generate();
response.set({