From 4b8e5bf3fc5f52b1621e93b6d2bd95ef5ce1c4d7 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 24 Jan 2021 17:47:03 +0100 Subject: [PATCH] Added qrCode helper test --- test/utils/helpers/qrCodes.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/utils/helpers/qrCodes.test.ts diff --git a/test/utils/helpers/qrCodes.test.ts b/test/utils/helpers/qrCodes.test.ts new file mode 100644 index 00000000..fe0a0f76 --- /dev/null +++ b/test/utils/helpers/qrCodes.test.ts @@ -0,0 +1,17 @@ +import { buildQrCodeUrl, QrCodeFormat } from '../../../src/utils/helpers/qrCodes'; + +describe('qrCodes', () => { + describe('buildQrCodeUrl', () => { + test.each([ + [ 'foo.com', 530, 'svg', { useSizeInPath: true, svgIsSupported: true }, 'foo.com/qr-code/530?format=svg' ], + [ 'foo.com', 530, 'png', { useSizeInPath: true, svgIsSupported: true }, 'foo.com/qr-code/530?format=png' ], + [ 'bar.io', 870, 'svg', { useSizeInPath: false, svgIsSupported: false }, 'bar.io/qr-code?size=870' ], + [ 'bar.io', 200, 'png', { useSizeInPath: false, svgIsSupported: true }, 'bar.io/qr-code?size=200&format=png' ], + [ 'bar.io', 200, 'svg', { useSizeInPath: false, svgIsSupported: true }, 'bar.io/qr-code?size=200&format=svg' ], + [ 'foo.net', 480, 'png', { useSizeInPath: true, svgIsSupported: false }, 'foo.net/qr-code/480' ], + [ 'foo.net', 480, 'svg', { useSizeInPath: true, svgIsSupported: false }, 'foo.net/qr-code/480' ], + ])('builds expected URL based in params', (shortUrl, size, format, capabilities, expectedUrl) => { + expect(buildQrCodeUrl(shortUrl, size, format as QrCodeFormat, capabilities)).toEqual(expectedUrl); + }); + }); +});