-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for XrmMockGenerator.Control doesn't expose static methods #9
AutoLookupControl.Mock.ts - Simplified Constructor/Property defintion - Made uiKeyPressableOptional UiStandardElement.Mock.ts - Added factory create method to simplify creation. Attribute.ts - Reordered the properties of createString. This is a breaking change, but it allows for just being able to specify Attribute.createString("lastname"), rather than being forced to populated all of the parameters. The order of the parameters have been updated to be in the most like order of setting the value. (i.e. many unit tests may be setting a control to visible, or enabling it. Very few will care about the format, and even fewer will be worry about the label or setting the maxLength. control.ts - The xrm-mock-generator has exposed an instance of Control, making the static methods impossible to call. Ideally, it makes more sense for the class to be static methods, but the attribute class was setup as an instance, and I elected to leave it. Not sure if it should be changed or not. Added test for the control being added with a label
- Loading branch information
1 parent
778dbca
commit 1ea0608
Showing
13 changed files
with
61 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
/// <reference types="xrm" /> | ||
import * as XrmMock from "../xrm-mock/index"; | ||
export default class Attribute { | ||
private Control; | ||
createBool(name: string, value: boolean): Xrm.Page.BooleanAttribute; | ||
createDate(name: string, value: Date, includeTime: boolean): Xrm.Page.DateAttribute; | ||
createLookup(name: string, lookup: Xrm.Page.LookupValue): Xrm.Page.LookupAttribute; | ||
createNumber(name: string, value: number, min?: number, max?: number, precision?: number): Xrm.Page.NumberAttribute; | ||
createOptionSet(name: string, options: Xrm.Page.OptionSetValue[]): Xrm.Page.OptionSetAttribute; | ||
createOptionSetOption(option: Xrm.Page.OptionSetValue): XrmMock.OptionSetValueMock; | ||
createString(name: string, value: string, label: string, format: Xrm.Page.StringAttributeFormat, maxLength: number, isVisible: boolean, isDisabled: boolean): XrmMock.StringAttributeMock; | ||
createString(name: string, value?: string, isVisible?: boolean, isDisabled?: boolean, format?: Xrm.Page.StringAttributeFormat, maxLength?: number, label?: string): XrmMock.StringAttributeMock; | ||
private createAttribute(name, value); | ||
private addAttribute(attribute); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import * as XrmMock from "../xrm-mock/index"; | ||
export default class Control { | ||
static createStringControl(name: string, label: string, isVisible: boolean, isDisabled: boolean, attribute: XrmMock.StringAttributeMock): void; | ||
private static createControl(name, label, isVisible?, controlType?); | ||
private static addControl(control); | ||
createString(attribute: XrmMock.StringAttributeMock, name?: string, isVisible?: boolean, isDisabled?: boolean, label?: string): void; | ||
private createControl(name, label, isVisible?, controlType?); | ||
private addControl(control); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
dist/xrm-mock/page/autolookupcontrol/autolookupcontrol.mock.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
dist/xrm-mock/page/uistandardelement/uistandardelement.mock.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
import * as XrmMock from "../xrm-mock/index"; | ||
|
||
import Ui from "./ui"; | ||
|
||
export default class Control { | ||
public static createStringControl(name: string, label: string, isVisible: boolean, isDisabled: boolean, | ||
attribute: XrmMock.StringAttributeMock): void { | ||
public createString(attribute: XrmMock.StringAttributeMock, name?: string, isVisible: boolean = true, isDisabled: boolean = false, label?: string): void { | ||
const stringControl = new XrmMock.StringControlMock( | ||
new XrmMock.AutoLookupControlMock( | ||
new XrmMock.StandardControlMock({ | ||
attribute, | ||
control: this.createControl(name, label, isVisible, "standard"), | ||
}), | ||
new XrmMock.UiKeyPressableMock())); | ||
control: this.createControl(name, label, isVisible), | ||
uiStandardElement: XrmMock.UiStandardElementMock.create(label,isVisible) | ||
}))); | ||
|
||
this.addControl(stringControl); | ||
} | ||
private static createControl(name: string, label: string, isVisible?: boolean, | ||
controlType?: Xrm.Page.ControlType): XrmMock.ControlMock { | ||
private createControl(name: string, label: string, isVisible?: boolean, | ||
controlType: Xrm.Page.ControlType = "standard"): XrmMock.ControlMock { | ||
const control = new XrmMock.ControlMock({ | ||
controlType: controlType || "standard", | ||
name, | ||
uiCanGetVisibleElement: Ui.createCanGetVisibleElement(isVisible || true), | ||
uiLabelElement: Ui.createLabelElement(label), | ||
uiLabelElement: Ui.createLabelElement(label || name), | ||
}); | ||
|
||
return control; | ||
} | ||
|
||
private static addControl(control: Xrm.Page.Control): void { | ||
private addControl(control: Xrm.Page.Control): void { | ||
(Xrm.Page.ui.controls as any).push(control); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/xrm-mock/page/uistandardelement/uistandardelement.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters