Removed checks for QR code features that were not supported on versions older than 2.6

This commit is contained in:
Alejandro Celaya
2022-05-01 10:44:12 +02:00
parent 9518ad9bb4
commit a949ec9e8e
4 changed files with 32 additions and 74 deletions

View File

@@ -3,71 +3,41 @@ import { buildQrCodeUrl, QrCodeFormat, QrErrorCorrection } from '../../../src/ut
describe('qrCodes', () => {
describe('buildQrCodeUrl', () => {
it.each([
[
'foo.com',
{ size: 530, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: false, errorCorrectionIsSupported: false },
'foo.com/qr-code/530?format=svg',
],
[
'foo.com',
{ size: 530, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: false, errorCorrectionIsSupported: false },
'foo.com/qr-code/530?format=png',
],
[
'bar.io',
{ size: 870, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: false, marginIsSupported: false, errorCorrectionIsSupported: false },
{ errorCorrectionIsSupported: false },
'bar.io/qr-code?size=870&format=svg',
],
[
'bar.io',
{ size: 200, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: false, marginIsSupported: false, errorCorrectionIsSupported: false },
{ errorCorrectionIsSupported: false },
'bar.io/qr-code?size=200&format=png',
],
[
'bar.io',
{ size: 200, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: false, marginIsSupported: false, errorCorrectionIsSupported: false },
{ errorCorrectionIsSupported: false },
'bar.io/qr-code?size=200&format=svg',
],
[
'foo.net',
{ size: 480, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: false, errorCorrectionIsSupported: false },
'foo.net/qr-code/480?format=png',
],
[
'foo.net',
{ size: 480, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: false, errorCorrectionIsSupported: false },
'foo.net/qr-code/480?format=svg',
],
[
'shlink.io',
{ size: 123, format: 'svg' as QrCodeFormat, margin: 10, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: false, errorCorrectionIsSupported: false },
'shlink.io/qr-code/123?format=svg',
],
[
'shlink.io',
{ size: 456, format: 'png' as QrCodeFormat, margin: 10, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: true, errorCorrectionIsSupported: false },
'shlink.io/qr-code/456?format=png&margin=10',
],
[
'shlink.io',
{ size: 456, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: true, errorCorrectionIsSupported: false },
'shlink.io/qr-code/456?format=png',
{ errorCorrectionIsSupported: false },
'shlink.io/qr-code?size=456&format=png&margin=10',
],
[
'shlink.io',
{ size: 456, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'H' as QrErrorCorrection },
{ useSizeInPath: true, marginIsSupported: true, errorCorrectionIsSupported: true },
'shlink.io/qr-code/456?format=png&errorCorrection=H',
{ errorCorrectionIsSupported: true },
'shlink.io/qr-code?size=456&format=png&errorCorrection=H',
],
[
'shlink.io',
{ size: 999, format: 'png' as QrCodeFormat, margin: 20, errorCorrection: 'Q' as QrErrorCorrection },
{ errorCorrectionIsSupported: true },
'shlink.io/qr-code?size=999&format=png&margin=20&errorCorrection=Q',
],
])('builds expected URL based in params', (shortUrl, options, capabilities, expectedUrl) => {
expect(buildQrCodeUrl(shortUrl, options, capabilities)).toEqual(expectedUrl);