Skip to content

Commit 161daff

Browse files
committed
115284: Add tests for isRepeatable
1 parent 1055475 commit 161daff

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.spec.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('EditRelationshipListComponent', () => {
110110
},
111111
};
112112

113-
function init(leftType: string, rightType: string): void {
113+
function init(leftType: string, rightType: string, leftMaxCardinality?: number, rightMaxCardinality?: number): void {
114114
entityTypeLeft = Object.assign(new ItemType(), {
115115
id: leftType,
116116
uuid: leftType,
@@ -130,6 +130,8 @@ describe('EditRelationshipListComponent', () => {
130130
rightType: createSuccessfulRemoteDataObject$(entityTypeRight),
131131
leftwardType: `is${rightType}Of${leftType}`,
132132
rightwardType: `is${leftType}Of${rightType}`,
133+
leftMaxCardinality: leftMaxCardinality,
134+
rightMaxCardinality: rightMaxCardinality,
133135
});
134136

135137
paginationOptions = Object.assign(new PaginationComponentOptions(), {
@@ -402,4 +404,31 @@ describe('EditRelationshipListComponent', () => {
402404
}));
403405
});
404406
});
407+
408+
describe('Is repeatable relationship', () => {
409+
beforeEach(waitForAsync(() => {
410+
currentItemIsLeftItem$ = new BehaviorSubject<boolean>(true);
411+
}));
412+
describe('when max cardinality is 1', () => {
413+
beforeEach(waitForAsync(() => init('Publication', 'OrgUnit', 1, undefined)));
414+
it('should return false', () => {
415+
const result = (comp as any).isRepeatable();
416+
expect(result).toBeFalse();
417+
});
418+
});
419+
describe('when max cardinality is 2', () => {
420+
beforeEach(waitForAsync(() => init('Publication', 'OrgUnit', 2, undefined)));
421+
it('should return true', () => {
422+
const result = (comp as any).isRepeatable();
423+
expect(result).toBeTrue();
424+
});
425+
});
426+
describe('when max cardinality is undefined', () => {
427+
beforeEach(waitForAsync(() => init('Publication', 'OrgUnit', undefined, undefined)));
428+
it('should return true', () => {
429+
const result = (comp as any).isRepeatable();
430+
expect(result).toBeTrue();
431+
});
432+
});
433+
});
405434
});

0 commit comments

Comments
 (0)