Fix MetadataRepresentationListElementComponent no expectation tests

Also fixed incorrect regex in isLink()
This commit is contained in:
Alexandre Vryghem
2023-07-01 13:13:27 +02:00
parent 3640d75e10
commit abc8640b5e
2 changed files with 4 additions and 8 deletions

View File

@@ -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,21 +39,17 @@ describe('MetadataRepresentationListElementComponent', () => {
comp.mdRepresentation = mockMetadataRepresentation;
});
it('isLink correctly detects a non-URL string as false', () => {
waitForAsync(() => {
expect(comp.isLink()).toBe(false);
});
});
});
describe('when the value is a URL', () => {
beforeEach(() => {
comp.mdRepresentation = mockMetadataRepresentationUrl;
});
it('isLink correctly detects a URL string as true', () => {
waitForAsync(() => {
expect(comp.isLink()).toBe(true);
});
});
});
});

View File

@@ -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());
}