From b209ef0824a8a6ba5be4dcdb5783a1a9facda158 Mon Sep 17 00:00:00 2001 From: Dmitry Kuzin Date: Fri, 10 Jan 2025 19:54:05 +0400 Subject: [PATCH] Fix unit tests --- src/flat_layout/flat_survey.ts | 2 +- tests/flat_survey.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/flat_layout/flat_survey.ts b/src/flat_layout/flat_survey.ts index d0dc334..b3f5b88 100644 --- a/src/flat_layout/flat_survey.ts +++ b/src/flat_layout/flat_survey.ts @@ -131,7 +131,7 @@ export class FlatSurvey { private static async generateFlatLogoImage(survey: SurveyPDF, controller: DocController, point: IPoint): Promise { const logoUrl = SurveyHelper.getLocString(survey.locLogo); - const logoSize = await SurveyHelper.getCorrectedImageSize(controller, { imageLink: logoUrl, imageHeight: survey.logoHeight, imageWidth: survey.logoWidth }); + const logoSize = await SurveyHelper.getCorrectedImageSize(controller, { imageLink: logoUrl, imageHeight: survey.logoHeight, imageWidth: survey.logoWidth, defaultImageWidth: '300px', defaultImageHeight: '200px' }); const logoFlat: IPdfBrick = await SurveyHelper.createImageFlat( point, null, controller, { link: logoUrl, width: logoSize.width, height: logoSize.height }); diff --git a/tests/flat_survey.test.ts b/tests/flat_survey.test.ts index 12483a9..94f7c9b 100644 --- a/tests/flat_survey.test.ts +++ b/tests/flat_survey.test.ts @@ -111,6 +111,8 @@ test('Survey with logo', async () => { SurveyHelper.shouldConvertImageToPng = false; const json: any = { logo: TestHelper.BASE64_IMAGE_16PX, + logoWidth: '300px', + logoHeight: '200px', pages: [] }; const survey: SurveyPDF = new SurveyPDF(json, TestHelper.defaultOptions); @@ -134,6 +136,8 @@ test('Survey with left logo and title', async () => { title: 'TitleLogoLeft', logo: TestHelper.BASE64_IMAGE_16PX, logoPosition: 'left', + logoWidth: '300px', + logoHeight: '200px', questions: [ { type: 'text', @@ -176,6 +180,8 @@ test('Survey with left logo and big title', async () => { title: 'TitleLogoLeftBiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiig', logo: TestHelper.BASE64_IMAGE_16PX, logoPosition: 'left', + logoWidth: '300px', + logoHeight: '200px', questions: [ { type: 'text', @@ -218,6 +224,8 @@ test('Survey with right logo and title', async () => { title: 'TitleRight', logo: TestHelper.BASE64_IMAGE_16PX, logoPosition: 'right', + logoWidth: '300px', + logoHeight: '200px', questions: [ { type: 'text', @@ -258,6 +266,8 @@ test('Survey with bottom logo and title', async () => { const json: any = { title: 'TitleLogoBottom', logo: TestHelper.BASE64_IMAGE_16PX, + logoWidth: '300px', + logoHeight: '200px', logoPosition: 'bottom', pages: [] }; @@ -291,6 +301,8 @@ test('Survey with botton logo without title', async () => { const json: any = { logo: TestHelper.BASE64_IMAGE_16PX, logoPosition: 'bottom', + logoWidth: '300px', + logoHeight: '200px', pages: [] }; const survey: SurveyPDF = new SurveyPDF(json, TestHelper.defaultOptions); @@ -343,6 +355,8 @@ test('Survey with logo server-side', async () => { test('Survey with logo and pages', async () => { const json: any = { logo: TestHelper.BASE64_IMAGE_16PX, + logoWidth: '300px', + logoHeight: '200px', pages: [ { name: 'page1',