From 73c511777c551e7ab9c441cf0d78ecc0fe0a630b Mon Sep 17 00:00:00 2001 From: Dmitry Kuzin Date: Wed, 25 Sep 2024 12:31:32 +0400 Subject: [PATCH] Mock jspdf version in snapshot tests --- tests/pdf_snapshots/long_comment.pdf | Bin 16804 -> 16803 bytes tests/pdf_snapshots/medium_comment.pdf | Bin 7603 -> 7602 bytes tests/pdf_snapshots/short_comment.pdf | Bin 4218 -> 4217 bytes tests/snapshot_helper.ts | 5 ++++- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/pdf_snapshots/long_comment.pdf b/tests/pdf_snapshots/long_comment.pdf index b961102a5fa0a847682a43535685ade57ca08fc8..d97bde9382a2d5831a0f58b342d8e86b16e05444 100644 GIT binary patch delta 33 ocmZ3|%(%FjaYLaUOG#>R$>uV+gRzitW_ delta 32 ocmdmFz1e!hMJZMzJySiy%~z%DnHY^Gi^@)8H{()Ob@g`x0J2yKOaK4? diff --git a/tests/pdf_snapshots/short_comment.pdf b/tests/pdf_snapshots/short_comment.pdf index 382671d0980acab90f21b35cbbb66e899facdb6b..d18277f02cb8ecde3dc6b743a7ac61d8ad0d37b3 100644 GIT binary patch delta 31 ncmeyR@Ka&K3|^L!)Z&uOb9wEV7|kZ%<)6lGz@@6{>hA^s#w7}z delta 32 ocmeyV@JnIC3|>|vJySiy&2xC|nHbF{-{GIeZpfvo>gw+X0J$Lv(EtDd diff --git a/tests/snapshot_helper.ts b/tests/snapshot_helper.ts index 3091745..5ae8136 100644 --- a/tests/snapshot_helper.ts +++ b/tests/snapshot_helper.ts @@ -3,7 +3,7 @@ import { DocController, FlatSurvey, IDocOptions, IPdfBrick } from '../src/entrie import { SurveyPDFTester, TestHelper } from '../src/helper_test'; import { SurveyPDF } from '../src/survey'; import { readFileSync, writeFileSync } from 'fs'; - +import jsPDF from 'jspdf'; interface IPDFSnapshotOptions { snapshotName: string; controllerOptions?: IDocOptions; @@ -11,6 +11,8 @@ interface IPDFSnapshotOptions { } export async function checkPDFSnapshot(surveyJSON: any, snapshotOptions: IPDFSnapshotOptions): Promise { + const jsPdfVersion = jsPDF.version; + jsPDF.version = 'test'; const survey = new SurveyPDFTester(surveyJSON, snapshotOptions.controllerOptions ?? TestHelper.defaultOptions); snapshotOptions.onSurveyCreated && snapshotOptions.onSurveyCreated(survey); survey.onDocControllerCreated.add((_, options) => { @@ -26,6 +28,7 @@ export async function checkPDFSnapshot(surveyJSON: any, snapshotOptions: IPDFSna const expected = readFileSync(fileName); expect(actual, `snapshot: "${snapshotName}" did not match`, { showMatcherMessage: false }).toEqual(expected); } + jsPDF.version = jsPdfVersion; } interface IFlatSnaphotOptions {