-
Notifications
You must be signed in to change notification settings - Fork 31
/
generator.test.ts
64 lines (48 loc) · 1.72 KB
/
generator.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { LookupValueMock } from "../../src/xrm-mock";
import { XrmMockGenerator } from "../../src/xrm-mock-generator/index";
describe("XrmMockGenerator", () => {
beforeEach(() => {
XrmMockGenerator.initialise();
});
it("should initialise Xrm globally", () => {
expect(Xrm).toBeDefined();
});
it("should have an Attribute property", () => {
expect(XrmMockGenerator.Attribute).toBeDefined();
});
it("should have a Control property", () => {
expect(XrmMockGenerator.Control).toBeDefined();
});
it("should have a Tab property", () => {
expect(XrmMockGenerator.Tab).toBeDefined();
});
it("should have a Section property", () => {
expect(XrmMockGenerator.Section).toBeDefined();
});
it("should default an event/execution context", () => {
expect(XrmMockGenerator.eventContext).toBeDefined();
});
it("should default a form context", () => {
expect(XrmMockGenerator.formContext).toBeDefined();
});
it("should persist a defaulted form context", () => {
XrmMockGenerator.initialise();
XrmMockGenerator.Attribute.createLookup("contactid", new LookupValueMock("5555", "contact", "Joe Bloggs"));
const expected = XrmMockGenerator.eventContext.getFormContext();
expect(expected).toBe(XrmMockGenerator.formContext);
});
it("should default entity name to contact", () => {
XrmMockGenerator.initialise();
const expected = Xrm.Page.data.entity.getEntityName();
expect(expected).toBe("contact");
});
it("should initialise given an entity name", () => {
XrmMockGenerator.initialise({
entity: {
entityName: "account",
},
});
const expected = Xrm.Page.data.entity.getEntityName();
expect(expected).toBe("account");
});
});