Skip to content

Commit

Permalink
add test for executionParams and requestbodyParams
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechGrancow committed Nov 15, 2023
1 parent 9ea749f commit 46c98b2
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { DeletionExecutionParams } from './deletion-execution.params';

describe(DeletionExecutionParams.name, () => {
describe('constructor', () => {
describe('when passed properties', () => {
let deletionExecutionParams: DeletionExecutionParams;

beforeEach(() => {
deletionExecutionParams = new DeletionExecutionParams();
});

it('should be defined', () => {
expect(deletionExecutionParams).toBeDefined();
});

it('should have a limit property', () => {
expect(deletionExecutionParams.limit).toBeDefined();
});

it('limit should be a number with a default value of 100', () => {
expect(deletionExecutionParams.limit).toBeDefined();
expect(typeof deletionExecutionParams.limit).toBe('number');
expect(deletionExecutionParams.limit).toBe(100);
});

it('limit should be optional', () => {
deletionExecutionParams.limit = undefined;
expect(deletionExecutionParams.limit).toBeUndefined();
});

it('limit should be a number when provided', () => {
const customLimit = 50;
deletionExecutionParams.limit = customLimit;
expect(deletionExecutionParams.limit).toBe(customLimit);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DeletionRequestBodyProps } from './deletion-request.body.params';

describe(DeletionRequestBodyProps.name, () => {
describe('constructor', () => {
describe('when passed properties', () => {
let deletionRequestBodyProps: DeletionRequestBodyProps;

beforeEach(() => {
deletionRequestBodyProps = new DeletionRequestBodyProps();
});

it('should be defined', () => {
expect(deletionRequestBodyProps).toBeDefined();
});

it('deleteInMinutes should be a number with default value 43200', () => {
expect(deletionRequestBodyProps.deleteInMinutes).toBeDefined();
expect(typeof deletionRequestBodyProps.deleteInMinutes).toBe('number');
expect(deletionRequestBodyProps.deleteInMinutes).toBe(43200);
});

it('deleteInMinutes should be optional', () => {
deletionRequestBodyProps.deleteInMinutes = undefined;
expect(deletionRequestBodyProps.deleteInMinutes).toBeUndefined();
});

it('deleteInMinutes should be a number when provided', () => {
const customDeleteInMinutes = 60;
deletionRequestBodyProps.deleteInMinutes = customDeleteInMinutes;
expect(deletionRequestBodyProps.deleteInMinutes).toBe(customDeleteInMinutes);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.en
import { DeletionRequestBodyProps } from '../../controller/dto';

export class DeletionRequestBodyPropsBuilder {
static build(domain: DeletionDomainModel, id: EntityId, deleteInMinutes: number): DeletionRequestBodyProps {
static build(domain: DeletionDomainModel, id: EntityId, deleteInMinutes?: number): DeletionRequestBodyProps {
const deletionRequest = {
targetRef: { domain, id },
deleteInMinutes,
Expand Down

0 comments on commit 46c98b2

Please sign in to comment.