Skip to content

Commit

Permalink
115284: Add tests for isRepeatable
Browse files Browse the repository at this point in the history
  • Loading branch information
YanaDePauw committed Oct 2, 2024
1 parent a559501 commit 876d94e
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('EditRelationshipListComponent', () => {
fixture.detectChanges();
};

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,
Expand All @@ -98,6 +98,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(), {
Expand Down Expand Up @@ -367,4 +369,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();
});
});
});
});

0 comments on commit 876d94e

Please sign in to comment.