Skip to content

Commit

Permalink
Replace old formatters (#686)
Browse files Browse the repository at this point in the history
* replace old formatters

* fix failed reason mock

* ignore config files in coverage report

* update the ignore pattern for config files
  • Loading branch information
Assem-Hafez authored Oct 1, 2024
1 parent a3d6ac4 commit 887646a
Show file tree
Hide file tree
Showing 26 changed files with 1,319 additions and 1,185 deletions.
19 changes: 10 additions & 9 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
const config= {
const config = {
collectCoverage: true,
coverageDirectory: "coverage",
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [
"/node_modules/",
"src/test-utils",
'/node_modules/',
'src/test-utils',
'\\.config\\.ts$',
],
coverageProvider: "v8",
coverageProvider: 'v8',
coverageThreshold: {
global: {
branches: 85,
functions: 85,
lines: 85,
statements: 85
}
statements: 85,
},
},
projects: [
'<rootDir>/jest/browser/jest.config.ts',
'<rootDir>/jest/node/jest.config.ts',
'<rootDir>/jest/tsd/jest.config.ts',
],
}
export default config;
};
export default config;
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { completeActivityTaskEvent } from '@/views/workflow-history/__fixtures__/workflow-history-activity-events';

import formatTimestampToDatetime from '../format-timestamp-to-datetime';
import formatWorkflowHistory from '../format-workflow-history';
import formatWorkflowHistoryEvent from '../format-workflow-history-event';
import formatWorkflowHistoryEventType from '../format-workflow-history-event-type';

jest.mock('../format-timestamp-to-datetime');
jest.mock('../format-workflow-history-event');
Expand All @@ -16,10 +17,6 @@ const mockedFormatWorkflowHistoryEvent =
formatWorkflowHistoryEvent as jest.MockedFunction<
typeof formatWorkflowHistoryEvent
>;
const mockedFormatWorkflowHistoryEventType =
formatWorkflowHistoryEventType as jest.MockedFunction<
typeof formatWorkflowHistoryEventType
>;

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

const input = {
archived: true,
history: {
events: [
{
eventId: '1',
eventTime: { seconds: '1234567890', nano: 0 },
attributes: 'workflowExecutionStartedEventAttributes',
},
],
events: [completeActivityTaskEvent],
},
rawHistory: ['raw event data'],
otherData: 'some other data',
Expand All @@ -54,10 +43,6 @@ describe('formatWorkflowHistory', () => {
history: {
events: [
{
eventId: 1,
timestamp: expectedTimestamp,
eventType: 'ActivityTaskCanceled',
attributes: 'workflowExecutionStartedEventAttributes',
formattedEvent: true,
},
],
Expand All @@ -67,16 +52,6 @@ describe('formatWorkflowHistory', () => {
};

expect(formatWorkflowHistory(input)).toEqual(expectedOutput);
expect(mockedFormatTimestampToDatetime).toHaveBeenCalledWith({
seconds: '1234567890',
nano: 0,
});
expect(mockedFormatWorkflowHistoryEvent).toHaveBeenCalledWith({
attributes: 'workflowExecutionStartedEventAttributes',
});
expect(formatWorkflowHistoryEventType).toHaveBeenCalledWith(
'workflowExecutionStartedEventAttributes'
);
});

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

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 887646a

Please sign in to comment.