umbraco-cypress-testhelpers
Version:
Test helpers for making Cypress tests for Umbraco solutions
55 lines (48 loc) • 1.1 kB
text/typescript
import faker from 'faker';
import camelize from 'camelize';
import { AliasHelper } from '../../../../helpers/aliasHelper';
export class DocumentTypePropertyBuilder {
parentBuilder;
alias;
value;
allowCultureVariant;
dataTypeId;
label;
sortOrder;
validation;
constructor(parentBuilder) {
this.parentBuilder = parentBuilder;
}
withDataTypeId(dataTypeId) {
this.dataTypeId = dataTypeId;
return this;
}
withLabel(label) {
this.label = label;
return this;
}
withAlias(alias) {
this.alias = alias;
return this;
}
withValue(value) {
this.value = value;
return this;
}
done() {
return this.parentBuilder;
}
build() {
const label = this.label || faker.random.uuid();
const alias = this.alias || 'a' + camelize(label);
return {
alias,
value: this.value || '',
allowCultureVariant: this.allowCultureVariant || false,
dataTypeId: this.dataTypeId || -1,
label,
sortOrder: this.sortOrder || 0,
validation: this.validation || { mandatory: false, pattern: null },
};
}
}