suitescript-mocks
Version:
Set of mocks for unit testing Netsuite Suitescript 2.*
84 lines (74 loc) • 1.86 kB
JavaScript
const { options, required, assignConstructor } = require("../../../helpers.cjs");
const serverWidgetStub = require("suitecloud-unit-testing-stubs/stubs/serverWidget.js");
class Field {
alias;
defaultValue;
helpText;
id;
isMandatory = false;
label;
linkText;
maxLength;
padding;
richTextHeight;
richTextWidth;
type;
source;
container;
help;
options = [];
height;
width;
addSelectOption = (options) => {
this.options.push(options);
};
// TODO
getSelectOptions = (options) => {
return this.options;
};
setHelpText = (options) => {
this.help = options.help;
return this;
};
updateBreakType = (options) => {
if (!Object.values(serverWidgetStub.FieldBreakType).includes(options.breakType)) {
throw new Error("Invalid value for breakType");
}
this.breakType = options.breakType;
return this;
};
updateDisplaySize = (options) => {
this.height = options.height;
this.width = options.width;
return this;
};
updateDisplayType = (options) => {
if (!Object.values(serverWidgetStub.FieldDisplayType).includes(options.displayType)) {
throw new Error("Invalid value for displayType");
}
this.displayType = options.displayType;
return this;
};
updateLayoutType = (options) => {
if (!Object.values(serverWidgetStub.FieldLayoutType).includes(options.layoutType)) {
throw new Error("Invalid value for layoutType");
}
this.layoutType = options.layoutType;
return this;
};
}
module.exports = Field;