115284: Add tests for isRepeatable

(cherry picked from commit 161daffcc0)
This commit is contained in:
Yana De Pauw
2024-10-02 09:23:26 +02:00
committed by github-actions[bot]
parent e4a464d44f
commit 48f7e51695

View File

@@ -110,7 +110,7 @@ describe('EditRelationshipListComponent', () => {
},
};
function init(leftType: string, rightType: string): void {
function init(leftType: string, rightType: string, leftMaxCardinality?: number, rightMaxCardinality?: number): void {
entityTypeLeft = Object.assign(new ItemType(), {
id: leftType,
uuid: leftType,
@@ -130,6 +130,8 @@ describe('EditRelationshipListComponent', () => {
rightType: createSuccessfulRemoteDataObject$(entityTypeRight),
leftwardType: `is${rightType}Of${leftType}`,
rightwardType: `is${leftType}Of${rightType}`,
leftMaxCardinality: leftMaxCardinality,
rightMaxCardinality: rightMaxCardinality,
});
paginationOptions = Object.assign(new PaginationComponentOptions(), {
@@ -402,4 +404,31 @@ describe('EditRelationshipListComponent', () => {
}));
});
});
describe('Is repeatable relationship', () => {
beforeEach(waitForAsync(() => {
currentItemIsLeftItem$ = new BehaviorSubject<boolean>(true);
}));
describe('when max cardinality is 1', () => {
beforeEach(waitForAsync(() => init('Publication', 'OrgUnit', 1, undefined)));
it('should return false', () => {
const result = (comp as any).isRepeatable();
expect(result).toBeFalse();
});
});
describe('when max cardinality is 2', () => {
beforeEach(waitForAsync(() => init('Publication', 'OrgUnit', 2, undefined)));
it('should return true', () => {
const result = (comp as any).isRepeatable();
expect(result).toBeTrue();
});
});
describe('when max cardinality is undefined', () => {
beforeEach(waitForAsync(() => init('Publication', 'OrgUnit', undefined, undefined)));
it('should return true', () => {
const result = (comp as any).isRepeatable();
expect(result).toBeTrue();
});
});
});
});