mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Fix MetadataRepresentationListElementComponent no expectation tests
Also fixed incorrect regex in isLink()
This commit is contained in:
@@ -19,7 +19,7 @@ describe('MetadataRepresentationListElementComponent', () => {
|
||||
let fixture: ComponentFixture<MetadataRepresentationListElementComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
return TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
declarations: [MetadataRepresentationListElementComponent],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
@@ -39,9 +39,7 @@ describe('MetadataRepresentationListElementComponent', () => {
|
||||
comp.mdRepresentation = mockMetadataRepresentation;
|
||||
});
|
||||
it('isLink correctly detects a non-URL string as false', () => {
|
||||
waitForAsync(() => {
|
||||
expect(comp.isLink()).toBe(false);
|
||||
});
|
||||
expect(comp.isLink()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,9 +48,7 @@ describe('MetadataRepresentationListElementComponent', () => {
|
||||
comp.mdRepresentation = mockMetadataRepresentationUrl;
|
||||
});
|
||||
it('isLink correctly detects a URL string as true', () => {
|
||||
waitForAsync(() => {
|
||||
expect(comp.isLink()).toBe(true);
|
||||
});
|
||||
expect(comp.isLink()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -25,7 +25,7 @@ export class MetadataRepresentationListElementComponent {
|
||||
*/
|
||||
isLink(): boolean {
|
||||
// Match any string that begins with http:// or https://
|
||||
const linkPattern = new RegExp(/^https?\/\/.*/);
|
||||
const linkPattern = new RegExp(/^https?:\/\/.*/);
|
||||
return linkPattern.test(this.mdRepresentation.getValue());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user