Skip to content

Commit

Permalink
test(core): removed comments
Browse files Browse the repository at this point in the history
removed extra comments

GH-78
  • Loading branch information
Deepika516 committed Mar 16, 2024
1 parent 1ec3f0f commit 2970e98
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ describe('GroupComponent', () => {
let nodeServiceSpy: any;
beforeEach(async () => {
const nodeServiceMock = {
getActions: () => [], // Implement a mock method to return an empty array or mock data
getActions: () => [],
getEvents: () => [],
getNodeByName: eventStub,
// getIdentifier: () => 'OnChangeEvent',

getGroupByName: () => {},
getGroups: () => [],
mapInputs: () => [],
Expand Down Expand Up @@ -184,16 +182,12 @@ describe('GroupComponent', () => {
expect(popper.hide).toHaveBeenCalled();
});

// Create a mock class for NgxPopperjsContentComponent

// Create a spy object to mock the methods of NgxPopperjsContentComponent
const popperSpy = jasmine.createSpyObj('NgxPopperjsContentComponent', [
'show',
'hide',
]);

it('should hide the previous popper and show the current popper', () => {
// Arrange
const event = new MouseEvent('click');
component.prevPopperRef = popperSpy; // Assign the spy object to prevPopperRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@ import {WorkflowAction} from './abstract-workflow-action.class';
import {AbstractWorkflowNode} from './abstract-workflow-node.class';

describe('WorkflowAction', () => {
let workflowAction: WorkflowAction<any>; // You may replace 'any' with a specific type for your test
let workflowAction: WorkflowAction<any>;

beforeEach(() => {
class MockAbstractWorkflowNode extends AbstractWorkflowNode<any> {
type = NodeTypes.ACTION;
statement: string;
prompts: string[];
state: any; // Replace 'any' with your specific state type
state: any;
name: string;
groupType: string; // Add groupType property
groupId: string; // Add groupId property
groupType: string;
groupId: string;
elements: any[];
isElseAction: boolean;
getIdentifier(): string {
// Implement the getIdentifier method as needed
return `${this.groupId}_${this.name}`;
}
// Mock other necessary methods or properties of AbstractWorkflowNode
}

workflowAction = new MockAbstractWorkflowNode(); // You need to implement MockWorkflowAction class
workflowAction = new MockAbstractWorkflowNode();
});

it('should have type set to NodeTypes.ACTION', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {AbstractBaseGroup} from '../nodes';
import {BuilderService} from './abstract-builder-service.class';
import {RecordOfAnyType} from '../../types';

// Mock implementation of BuilderService for testing
class MockBuilderService<E, S extends RecordOfAnyType> extends BuilderService<
E,
S
Expand Down Expand Up @@ -40,27 +39,20 @@ describe('BuilderService', () => {
let builderService: BuilderService<any, any>;

beforeEach(() => {
// Create an instance of the BuilderService with the mock implementation
builderService = new MockBuilderService();
});

it('should build and return a string', async () => {
// Create dummy statements
const statement: Statement<any> = {} as any;
const elseStatement: Statement<any> = {} as any;

// Call the build method
const result = await builderService.build(statement, elseStatement);

// Check if the result is a string
expect(typeof result).toBe('string');
});

it('should restore and return the expected structure', async () => {
// Call the restore method
const restoredModel = await builderService.restore('mocked-model');

// Check if the returned object has the expected properties
expect(restoredModel.actions).toBeDefined();
expect(restoredModel.elseActions).toBeDefined();
expect(restoredModel.events).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe('StatementNode', () => {
let mockNode: WorkflowNode<any>;

beforeEach(() => {
// Create mock instances for WorkflowElement and WorkflowNode
// mock instances for WorkflowElement and WorkflowNode
mockElement = {} as WorkflowElement<any>;
mockNode = {} as WorkflowNode<any>;

// Create a new StatementNode instance before each test
// a new StatementNode instance before each test
statementNode = new StatementNode(mockElement, mockNode);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ describe('Error Classes', () => {
let missingError: MissingError;

beforeEach(() => {
// Create instances of error classes before each test
invalidEntityError = new InvalidEntityError('testEntity');
notProvidedError = new NotProvided('testName');
missingError = new MissingError('testName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import {StatementNode} from '../classes';
import {WorkflowElement} from '../classes/element/abstract-element.class';
import {LinkStrategy} from './link-strategy.interface';

// Mock class for WorkflowElement
class MockWorkflowElement<T> extends WorkflowElement<T> {
// Implement any abstract methods with mock implementations
tag: any;
attributes: any;
name: any;
Expand All @@ -21,30 +19,24 @@ describe('LinkStrategy', () => {
let linkStrategy: LinkStrategy<any>;

beforeEach(() => {
// Initialize any necessary setup before each test
linkStrategy = {
// Mock implementation of the execute method
execute: (
element: WorkflowElement<any>,
node: StatementNode<any>,
): any[] => {
// Mock implementation, return an empty array for now
return [];
},
};
});

it('should implement the execute method', () => {
// Ensure that the execute method is implemented
expect(linkStrategy.execute).toBeDefined();
});

it('execute method should return an empty array', () => {
// Test the behavior of the execute method
const mockElement = new MockWorkflowElement<any>(); // Create a mock WorkflowElement
const mockNode = new StatementNode<any>(mockElement); // Create a mock StatementNode
const mockElement = new MockWorkflowElement<any>();
const mockNode = new StatementNode<any>(mockElement);

// Call the execute method and expect it to return an empty array
const result = linkStrategy.execute(mockElement, mockNode);
expect(result).toEqual([]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('TriggerOnAddItem', () => {
let triggerOnAddItem: TriggerOnAddItem;
let createStrategy: CreateStrategy<ModdleElement>;
let linkStrategy: LinkStrategy<ModdleElement>;
let env: any; // Mocked environment
let env: any;
let utilsService: UtilsService;

beforeEach(() => {
Expand Down Expand Up @@ -60,6 +60,4 @@ describe('TriggerOnAddItem', () => {
it('should have the correct outputs', () => {
expect(triggerOnAddItem.outputs).toEqual('outputVariable');
});

// Add more test cases as needed
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('TriggerWhenColumnChanges', () => {
let triggerWhenColumnChanges: TriggerWhenColumnChanges;
let createStrategy: CreateStrategy<ModdleElement>;
let linkStrategy: LinkStrategy<ModdleElement>;
let env: any; // Mocked environment
let env: any;
let utilsService: UtilsService;

beforeEach(() => {
Expand Down Expand Up @@ -62,6 +62,4 @@ describe('TriggerWhenColumnChanges', () => {
it('should have the correct outputs', () => {
expect(triggerWhenColumnChanges.outputs).toEqual('outputVariable');
});

// Add more test cases as needed
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,17 @@ describe('CreateBasicIntervalStrategy', () => {
workflowNode: {state: new Map([['someStateKey', 'mockedStateValue']])},
};

// Calling the method under test
const result = service['parseAttributes'](attrs, node);

// Expectations
expect(result).toEqual({someAttr: 'mockedStateValue'});
});

it('should leave non-state reference attributes unchanged', () => {
// Mocking necessary data
const attrs: RecordOfAnyType = {someAttr: 'someValue'};
const node: any = {workflowNode: {state: new Map()}};

// Calling the method under test
const result = service['parseAttributes'](attrs, node);

// Expectations
expect(result).toEqual(attrs);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ describe('CreateGatewayStrategy', () => {

describe('parseAttributes', () => {
it('should parse state references in attributes', () => {
const attrs = {}; // Provide mock attributes
const node = {} as BpmnStatementNode; // Provide a mock of BpmnStatementNode
const attrs = {};
const node = {} as BpmnStatementNode;

const parsedAttrs = service['parseAttributes'](attrs, node);

// Add expectations/assertions here
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {AndGroup} from './and.group';

describe('AndGroup', () => {
let group: AndGroup<any>;
let localizedStringMap: RecordOfAnyType = {}; // You can add mock localized string data here
let localizedStringMap: RecordOfAnyType = {};
let id = '';
let type = NodeTypes.GROUP;
let isElseGroup = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {OrGroup} from './or.group';

describe('OrGroup', () => {
let group: OrGroup<any>;
let localizedStringMap: RecordOfAnyType = {}; // You can add mock localized string data here
let localizedStringMap: RecordOfAnyType = {};
let id = '';
let type = NodeTypes.GROUP;

Expand Down

0 comments on commit 2970e98

Please sign in to comment.