camelCaseDave / xrm-mock

:books: A fake implementation of the Xrm object model. Written in TypeScript against @types/xrm definitions.
MIT License
79 stars 31 forks source link

Pass eventContext to attribute onChange Handlers #62

Closed scottdurow closed 3 years ago

scottdurow commented 3 years ago

Fixes #44

This test will now pass:

it("should fire OnChange with eventContext", () => {
    const onChangeEventMock = jest.fn();
    attribute.addOnChange(onChangeEventMock);
    attribute.fireOnChange();
    expect(onChangeEventMock).toBeCalledWith(XrmMockGenerator.getEventContext());
});

See https://github.com/scottdurow/xrm-mock/blob/0ccb168c5d19d712a0ea16a7c43e4b1e4e5fbfc7/test/xrm-mock-generator/builder.test.ts#L282

Note: Now that XrmMockGenerator is imported into attribute.mock.ts - there was an import order issue with the tests - so I've refactored the imports on the tests that were failing.

camelCaseDave commented 3 years ago

Thanks @scottdurow. I've built and published a latest version 3.5.1 including your changes. https://www.npmjs.com/package/xrm-mock