mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 03:53:02 +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>;
|
let fixture: ComponentFixture<MetadataRepresentationListElementComponent>;
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
return TestBed.configureTestingModule({
|
||||||
imports: [],
|
imports: [],
|
||||||
declarations: [MetadataRepresentationListElementComponent],
|
declarations: [MetadataRepresentationListElementComponent],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
@@ -39,21 +39,17 @@ describe('MetadataRepresentationListElementComponent', () => {
|
|||||||
comp.mdRepresentation = mockMetadataRepresentation;
|
comp.mdRepresentation = mockMetadataRepresentation;
|
||||||
});
|
});
|
||||||
it('isLink correctly detects a non-URL string as false', () => {
|
it('isLink correctly detects a non-URL string as false', () => {
|
||||||
waitForAsync(() => {
|
|
||||||
expect(comp.isLink()).toBe(false);
|
expect(comp.isLink()).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the value is a URL', () => {
|
describe('when the value is a URL', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
comp.mdRepresentation = mockMetadataRepresentationUrl;
|
comp.mdRepresentation = mockMetadataRepresentationUrl;
|
||||||
});
|
});
|
||||||
it('isLink correctly detects a URL string as true', () => {
|
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 {
|
isLink(): boolean {
|
||||||
// Match any string that begins with http:// or https://
|
// 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());
|
return linkPattern.test(this.mdRepresentation.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user