Skip to content

Commit 89c9eb3

Browse files
authored
Merge pull request #77 from arushsaxena1998/DOT-3058
Fixing null checks
2 parents 1f900ff + d47b75f commit 89c9eb3

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

commands/utils/validate.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -212,28 +212,28 @@ function validateCustomViewPorts(customViewports) {
212212
if (!element.styles?.width) {
213213
throw new ValidationError('Missing width in styles. please check the config file');
214214
}
215+
let width = element.styles.width;
216+
let height = element.styles.height;
217+
if (width && typeof width != 'number') {
218+
width = Number(width);
219+
}
220+
if (height && typeof height != 'number') {
221+
height = Number(height);
222+
}
223+
if (width && width < MIN_RESOLUTION_WIDTH || width > MAX_RESOLUTION_WIDTH) {
224+
throw new ValidationError(`customViewports.styles width must be > ${MIN_RESOLUTION_WIDTH}, < ${MAX_RESOLUTION_WIDTH}`);
225+
}
226+
if (height & (height < MIN_RESOLUTION_WIDTH || height > MAX_RESOLUTION_WIDTH)) {
227+
throw new ValidationError(`customViewports.styles height must be > ${MIN_RESOLUTION_HEIGHT}, < ${MAX_RESOLUTION_HEIGHT}`);
228+
}
229+
element.styles.width = width;
230+
element.styles.height = height;
215231
} else {
216232
if (!element.waitForTimeout) {
217233
throw new ValidationError('Missing styles and waitForTimeout. Specify either of them. please check the config file');
218234
}
219235
}
220236

221-
let width = element.styles.width;
222-
let height = element.styles.height;
223-
if (width && typeof width != 'number') {
224-
width = Number(width);
225-
}
226-
if (height && typeof height != 'number') {
227-
height = Number(height);
228-
}
229-
if (width && width < MIN_RESOLUTION_WIDTH || width > MAX_RESOLUTION_WIDTH) {
230-
throw new ValidationError(`customViewports.styles width must be > ${MIN_RESOLUTION_WIDTH}, < ${MAX_RESOLUTION_WIDTH}`);
231-
}
232-
if (height & (height < MIN_RESOLUTION_WIDTH || height > MAX_RESOLUTION_WIDTH)) {
233-
throw new ValidationError(`customViewports.styles height must be > ${MIN_RESOLUTION_HEIGHT}, < ${MAX_RESOLUTION_HEIGHT}`);
234-
}
235-
element.styles.width = width;
236-
element.styles.height = height;
237237
});
238238
return
239239
}

0 commit comments

Comments
 (0)