Skip to content

Commit

Permalink
Fix moment mock
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Feb 24, 2020
1 parent 1891137 commit e28ea25
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/telemetry/public/services/telemetry_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@ const mockSubtract = jest.fn().mockImplementation(() => {
};
});

const mockClone = jest.fn().mockImplementation(() => {
return {
clone: mockClone,
subtract: mockSubtract,
toISOString: jest.fn(),
};
});

jest.mock('moment', () => {
return jest.fn().mockImplementation(() => {
return {
clone: mockClone,
subtract: mockSubtract,
toISOString: jest.fn(),
};
Expand All @@ -43,6 +52,7 @@ describe('TelemetryService', () => {
expect(telemetryService['http'].post).toBeCalledWith('/api/telemetry/v2/clusters/_stats', {
body: JSON.stringify({ unencrypted: false, timeRange: {} }),
});
expect(mockClone).toBeCalled();
expect(mockSubtract).toBeCalledWith(20, 'minutes');
});
});
Expand Down

0 comments on commit e28ea25

Please sign in to comment.