Skip to content

Commit 887646a

Browse files
authored
Replace old formatters (#686)
* replace old formatters * fix failed reason mock * ignore config files in coverage report * update the ignore pattern for config files
1 parent a3d6ac4 commit 887646a

26 files changed

+1319
-1185
lines changed

jest.config.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
const config= {
1+
const config = {
22
collectCoverage: true,
3-
coverageDirectory: "coverage",
3+
coverageDirectory: 'coverage',
44
coveragePathIgnorePatterns: [
5-
"/node_modules/",
6-
"src/test-utils",
5+
'/node_modules/',
6+
'src/test-utils',
7+
'\\.config\\.ts$',
78
],
8-
coverageProvider: "v8",
9+
coverageProvider: 'v8',
910
coverageThreshold: {
1011
global: {
1112
branches: 85,
1213
functions: 85,
1314
lines: 85,
14-
statements: 85
15-
}
15+
statements: 85,
16+
},
1617
},
1718
projects: [
1819
'<rootDir>/jest/browser/jest.config.ts',
1920
'<rootDir>/jest/node/jest.config.ts',
2021
'<rootDir>/jest/tsd/jest.config.ts',
2122
],
22-
}
23-
export default config;
23+
};
24+
export default config;

src/utils/data-formatters/__tests__/format-workflow-history.test.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { completeActivityTaskEvent } from '@/views/workflow-history/__fixtures__/workflow-history-activity-events';
2+
13
import formatTimestampToDatetime from '../format-timestamp-to-datetime';
24
import formatWorkflowHistory from '../format-workflow-history';
35
import formatWorkflowHistoryEvent from '../format-workflow-history-event';
4-
import formatWorkflowHistoryEventType from '../format-workflow-history-event-type';
56

67
jest.mock('../format-timestamp-to-datetime');
78
jest.mock('../format-workflow-history-event');
@@ -16,10 +17,6 @@ const mockedFormatWorkflowHistoryEvent =
1617
formatWorkflowHistoryEvent as jest.MockedFunction<
1718
typeof formatWorkflowHistoryEvent
1819
>;
19-
const mockedFormatWorkflowHistoryEventType =
20-
formatWorkflowHistoryEventType as jest.MockedFunction<
21-
typeof formatWorkflowHistoryEventType
22-
>;
2320

2421
describe('formatWorkflowHistory', () => {
2522
beforeEach(() => {
@@ -29,21 +26,13 @@ describe('formatWorkflowHistory', () => {
2926
it('should format workflow history correctly', () => {
3027
const expectedTimestamp = new Date('2023-06-18T12:34:56.Z');
3128
mockedFormatTimestampToDatetime.mockReturnValue(expectedTimestamp);
29+
//@ts-expect-error using mock value that doesn't match formatting schema for easier validation
3230
mockedFormatWorkflowHistoryEvent.mockReturnValue({ formattedEvent: true });
33-
mockedFormatWorkflowHistoryEventType.mockReturnValue(
34-
'ActivityTaskCanceled'
35-
);
3631

3732
const input = {
3833
archived: true,
3934
history: {
40-
events: [
41-
{
42-
eventId: '1',
43-
eventTime: { seconds: '1234567890', nano: 0 },
44-
attributes: 'workflowExecutionStartedEventAttributes',
45-
},
46-
],
35+
events: [completeActivityTaskEvent],
4736
},
4837
rawHistory: ['raw event data'],
4938
otherData: 'some other data',
@@ -54,10 +43,6 @@ describe('formatWorkflowHistory', () => {
5443
history: {
5544
events: [
5645
{
57-
eventId: 1,
58-
timestamp: expectedTimestamp,
59-
eventType: 'ActivityTaskCanceled',
60-
attributes: 'workflowExecutionStartedEventAttributes',
6146
formattedEvent: true,
6247
},
6348
],
@@ -67,16 +52,6 @@ describe('formatWorkflowHistory', () => {
6752
};
6853

6954
expect(formatWorkflowHistory(input)).toEqual(expectedOutput);
70-
expect(mockedFormatTimestampToDatetime).toHaveBeenCalledWith({
71-
seconds: '1234567890',
72-
nano: 0,
73-
});
74-
expect(mockedFormatWorkflowHistoryEvent).toHaveBeenCalledWith({
75-
attributes: 'workflowExecutionStartedEventAttributes',
76-
});
77-
expect(formatWorkflowHistoryEventType).toHaveBeenCalledWith(
78-
'workflowExecutionStartedEventAttributes'
79-
);
8055
});
8156

8257
it('should set archived to null if not provided', () => {

src/utils/data-formatters/format-workflow-history-event/__tests__/format-workflow-execution-cancel-requested-event-attributes.test.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/utils/data-formatters/format-workflow-history-event/__tests__/format-workflow-execution-canceled-event-attributes.test.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/utils/data-formatters/format-workflow-history-event/__tests__/format-workflow-execution-completed-event-attributes.test.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)