Skip to content

Commit

Permalink
Mock queueMicrotask in unit tests (#314)
Browse files Browse the repository at this point in the history
* Update jest to support queueMircotask

* Do not use row.visibleElement in pdf

* Revert "Update jest to support queueMircotask"

This reverts commit a043c85.

* Mock queueMircotask in unit tests
  • Loading branch information
dk981234 authored Apr 23, 2024
1 parent 770c1a2 commit 088f0d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
tsConfig: "tsconfig.test.json"
}
},
setupFiles: ["<rootDir>/setupFile.js"],
reporters: [
"default",
[ "jest-junit", {
Expand Down
1 change: 1 addition & 0 deletions setupFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.queueMicrotask = (cb) => { cb(); }
9 changes: 5 additions & 4 deletions src/flat_layout/flat_survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ export class FlatSurvey {
const width: number = SurveyHelper.getPageAvailableWidth(controller);
let nextMarginLeft: number = controller.margins.left;
const rowFlats: IPdfBrick[] = [];
for (let i: number = 0; i < row.visibleElements.length; i++) {
let element: IElement = row.visibleElements[i];
const visibleElements = row.elements.filter(el => el.isVisible);
for (let i: number = 0; i < visibleElements.length; i++) {
let element: IElement = visibleElements[i];
if (!element.isVisible) continue;
const persWidth: number = SurveyHelper.parseWidth(element.renderWidth,
width - (row.visibleElements.length - 1) * controller.unitWidth,
row.visibleElements.length);
width - (visibleElements.length - 1) * controller.unitWidth,
visibleElements.length);
controller.margins.left = nextMarginLeft + ((i !== 0) ? controller.unitWidth : 0);
controller.margins.right = controller.paperWidth - controller.margins.left - persWidth;
currPoint.xLeft = controller.margins.left;
Expand Down

0 comments on commit 088f0d8

Please sign in to comment.