Closed marchaos closed 4 years ago
Some API Additions to support deep mocks and mock implementations. Note that this should not affect any existing usages of the API
Deep Mocks
test('can deep mock members', () => { const mockObj = mockDeep<Test1>(); mockObj.deepProp.getNumber.calledWith(1).mockReturnValue(4); expect(mockObj.deepProp.getNumber(1)).toBe(4); });
Mock Implementations
const mockObj = mock<Test1>({ id: 61 }); expect(mockObj.id).toBe(61);
Deep Mocks with mock implementation
const mockObj = mockDeep<Test1>({ deepProp: { getNumber: (num: number) => { return 76; } } }); expect(mockObj.deepProp.getNumber(123)).toBe(76);
Some API Additions to support deep mocks and mock implementations. Note that this should not affect any existing usages of the API
Deep Mocks
Mock Implementations
Deep Mocks with mock implementation