mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-12-15 13:39:40 -06:00
Added missing props on qrCodes test
This commit is contained in:
parent
c6be8bd96f
commit
37a3a2022b
@ -36,7 +36,7 @@ const QrCodeModal = (imageDownloader: ImageDownloader, ForServerVersion: FC<Vers
|
|||||||
svgIsSupported: supportsQrCodeSvgFormat(selectedServer),
|
svgIsSupported: supportsQrCodeSvgFormat(selectedServer),
|
||||||
marginIsSupported: supportsQrCodeMargin(selectedServer),
|
marginIsSupported: supportsQrCodeMargin(selectedServer),
|
||||||
errorCorrectionIsSupported: supportsQrErrorCorrection(selectedServer),
|
errorCorrectionIsSupported: supportsQrErrorCorrection(selectedServer),
|
||||||
}) as QrCodeCapabilities, [ selectedServer ]);
|
}), [ selectedServer ]);
|
||||||
const qrCodeUrl = useMemo(
|
const qrCodeUrl = useMemo(
|
||||||
() => buildQrCodeUrl(shortUrl, { size, format, margin, errorCorrection }, capabilities),
|
() => buildQrCodeUrl(shortUrl, { size, format, margin, errorCorrection }, capabilities),
|
||||||
[ shortUrl, size, format, margin, errorCorrection, capabilities ],
|
[ shortUrl, size, format, margin, errorCorrection, capabilities ],
|
||||||
|
|||||||
@ -1,68 +1,74 @@
|
|||||||
import { buildQrCodeUrl, QrCodeFormat } from '../../../src/utils/helpers/qrCodes';
|
import { buildQrCodeUrl, QrCodeFormat, QrErrorCorrection } from '../../../src/utils/helpers/qrCodes';
|
||||||
|
|
||||||
describe('qrCodes', () => {
|
describe('qrCodes', () => {
|
||||||
describe('buildQrCodeUrl', () => {
|
describe('buildQrCodeUrl', () => {
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'foo.com',
|
'foo.com',
|
||||||
{ size: 530, format: 'svg' as QrCodeFormat, margin: 0 },
|
{ size: 530, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: false },
|
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'foo.com/qr-code/530?format=svg',
|
'foo.com/qr-code/530?format=svg',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'foo.com',
|
'foo.com',
|
||||||
{ size: 530, format: 'png' as QrCodeFormat, margin: 0 },
|
{ size: 530, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: false },
|
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'foo.com/qr-code/530?format=png',
|
'foo.com/qr-code/530?format=png',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'bar.io',
|
'bar.io',
|
||||||
{ size: 870, format: 'svg' as QrCodeFormat, margin: 0 },
|
{ size: 870, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: false, svgIsSupported: false, marginIsSupported: false },
|
{ useSizeInPath: false, svgIsSupported: false, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'bar.io/qr-code?size=870',
|
'bar.io/qr-code?size=870',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'bar.io',
|
'bar.io',
|
||||||
{ size: 200, format: 'png' as QrCodeFormat, margin: 0 },
|
{ size: 200, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: false, svgIsSupported: true, marginIsSupported: false },
|
{ useSizeInPath: false, svgIsSupported: true, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'bar.io/qr-code?size=200&format=png',
|
'bar.io/qr-code?size=200&format=png',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'bar.io',
|
'bar.io',
|
||||||
{ size: 200, format: 'svg' as QrCodeFormat, margin: 0 },
|
{ size: 200, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: false, svgIsSupported: true, marginIsSupported: false },
|
{ useSizeInPath: false, svgIsSupported: true, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'bar.io/qr-code?size=200&format=svg',
|
'bar.io/qr-code?size=200&format=svg',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'foo.net',
|
'foo.net',
|
||||||
{ size: 480, format: 'png' as QrCodeFormat, margin: 0 },
|
{ size: 480, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: false, marginIsSupported: false },
|
{ useSizeInPath: true, svgIsSupported: false, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'foo.net/qr-code/480',
|
'foo.net/qr-code/480',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'foo.net',
|
'foo.net',
|
||||||
{ size: 480, format: 'svg' as QrCodeFormat, margin: 0 },
|
{ size: 480, format: 'svg' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: false, marginIsSupported: false },
|
{ useSizeInPath: true, svgIsSupported: false, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'foo.net/qr-code/480',
|
'foo.net/qr-code/480',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'shlink.io',
|
'shlink.io',
|
||||||
{ size: 123, format: 'svg' as QrCodeFormat, margin: 10 },
|
{ size: 123, format: 'svg' as QrCodeFormat, margin: 10, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: false, marginIsSupported: false },
|
{ useSizeInPath: true, svgIsSupported: false, marginIsSupported: false, errorCorrectionIsSupported: false },
|
||||||
'shlink.io/qr-code/123',
|
'shlink.io/qr-code/123',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'shlink.io',
|
'shlink.io',
|
||||||
{ size: 456, format: 'png' as QrCodeFormat, margin: 10 },
|
{ size: 456, format: 'png' as QrCodeFormat, margin: 10, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: true },
|
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: true, errorCorrectionIsSupported: false },
|
||||||
'shlink.io/qr-code/456?format=png&margin=10',
|
'shlink.io/qr-code/456?format=png&margin=10',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'shlink.io',
|
'shlink.io',
|
||||||
{ size: 456, format: 'png' as QrCodeFormat, margin: 0 },
|
{ size: 456, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'L' as QrErrorCorrection },
|
||||||
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: true },
|
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: true, errorCorrectionIsSupported: false },
|
||||||
'shlink.io/qr-code/456?format=png',
|
'shlink.io/qr-code/456?format=png',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'shlink.io',
|
||||||
|
{ size: 456, format: 'png' as QrCodeFormat, margin: 0, errorCorrection: 'H' as QrErrorCorrection },
|
||||||
|
{ useSizeInPath: true, svgIsSupported: true, marginIsSupported: true, errorCorrectionIsSupported: true },
|
||||||
|
'shlink.io/qr-code/456?format=png&errorCorrection=H',
|
||||||
|
],
|
||||||
])('builds expected URL based in params', (shortUrl, options, capabilities, expectedUrl) => {
|
])('builds expected URL based in params', (shortUrl, options, capabilities, expectedUrl) => {
|
||||||
expect(buildQrCodeUrl(shortUrl, options, capabilities)).toEqual(expectedUrl);
|
expect(buildQrCodeUrl(shortUrl, options, capabilities)).toEqual(expectedUrl);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user