115284: Add tests for isRepeatable

This commit is contained in:
Yana De Pauw
2024-10-02 09:23:26 +02:00
parent 105547598f
commit 161daffcc0

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(), { entityTypeLeft = Object.assign(new ItemType(), {
id: leftType, id: leftType,
uuid: leftType, uuid: leftType,
@@ -130,6 +130,8 @@ describe('EditRelationshipListComponent', () => {
rightType: createSuccessfulRemoteDataObject$(entityTypeRight), rightType: createSuccessfulRemoteDataObject$(entityTypeRight),
leftwardType: `is${rightType}Of${leftType}`, leftwardType: `is${rightType}Of${leftType}`,
rightwardType: `is${leftType}Of${rightType}`, rightwardType: `is${leftType}Of${rightType}`,
leftMaxCardinality: leftMaxCardinality,
rightMaxCardinality: rightMaxCardinality,
}); });
paginationOptions = Object.assign(new PaginationComponentOptions(), { 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();
});
});
});
}); });