Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var createAttribute = function (name, value) {
var attribute = new XrmMock.AttributeMock({
name: name,
value: value,
isDirty: false,
submitMode: "dirty"
});
return attribute;
};
Ui.prototype.createUi = function () {
return new XrmMock.UiMock({
controls: new XrmMock.ItemCollectionMock([]),
formSelector: new XrmMock.FormSelectorMock(new XrmMock.ItemCollectionMock([
Form.createBlankForm()
]))
});
};
Ui.prototype.createUi = function () {
return new XrmMock.UiMock({
controls: new XrmMock.ItemCollectionMock([]),
formSelector: new XrmMock.FormSelectorMock(new XrmMock.ItemCollectionMock([
Form.createBlankForm()
]))
});
};
XrmMockGenerator.prototype.initialise = function () {
var Xrm = new XrmMock.XrmStaticMock({
page: new XrmMock.PageMock({
context: new XrmMock.ContextMock({
userRoles: []
}),
data: new XrmMock.DataMock(
new XrmMock.EntityMock(
"{00000000-0000-0000-0000-000000000000}",
new XrmMock.ItemCollectionMock([]))),
ui: Ui.createUi()
})
});
return global.Xrm = Xrm;
};
Attribute.prototype.createOptionSet = function (name, options) {
var optionSetOptions = [];
if (options && options.length > 0) {
for (var i = 0; i < options.length; i++) {
var option = options[i];
optionSetOptions.push(new XrmMock.OptionSetValueMock(option.name, option.value));
}
}
var attribute = createAttribute(name, options[0]);
var enumAttribute = new XrmMock.EnumAttributeMock(attribute);
var optionSetAttribute = new XrmMock.OptionSetAttributeMock(enumAttribute, optionSetOptions);
addAttribute(optionSetAttribute);
return optionSetAttribute;
};
Attribute.prototype.createOptionSetOption = function (name, value) {
return new XrmMock.OptionSetValueMock(name, value);
};
Control.prototype.createStringControl = function (name, label, isVisible, isDisabled, attribute) {
var stringControl = new XrmMock.StringControlMock(
new XrmMock.AutoLookupControlMock(
new XrmMock.StandardControlMock({
control: createControl(name, label, isVisible),
attribute: attribute,
disabled: isDisabled,
uiStandardElement: Ui.createStandardElement(label, isVisible)
}),
new XrmMock.UiKeyPressableMock()
)
);
addControl(stringControl);
};
Attribute.prototype.createBool = function (name, value) {
var attribute = createAttribute(name || "", value || false);
var boolAttribute = new XrmMock.BooleanAttributeMock(attribute);
addAttribute(boolAttribute);
return boolAttribute;
};
XrmMockGenerator.prototype.initialise = function () {
var Xrm = new XrmMock.XrmStaticMock({
page: new XrmMock.PageMock({
context: new XrmMock.ContextMock({
userRoles: []
}),
data: new XrmMock.DataMock(
new XrmMock.EntityMock(
"{00000000-0000-0000-0000-000000000000}",
new XrmMock.ItemCollectionMock([]))),
ui: Ui.createUi()
})
});
return global.Xrm = Xrm;
};
var createControl = function (name, label, isVisible, controlType) {
var control = new XrmMock.ControlMock({
name: name,
controlType: controlType,
uiLabelElement: Ui.createLabelElement(label),
uiCanGetVisibleElement: Ui.createCanGetVisibleElement(isVisible)
});
};