Skip to content

Commit c9e346a

Browse files
Mattia VianelliMattia Vianelli
authored andcommitted
DURACOM-393 Review fixes
1 parent 756145f commit c9e346a

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/app/item-page/simple/field-components/specific-field/orcid/item-page-orcid-field.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="item-page-field mb-2">
33
<label class="font-weight-bold">{{ label | translate }}</label>
44
<a [href]="orcidUrl$ | async" target="_blank" rel="noopener noreferrer" class="d-flex align-items-center">
5-
<img [src]="img.URI" [alt]="img.alt | translate" [style]="'height: var(' + img.heightVar + ', 16px); margin-right: 8px;'" />
5+
<img [src]="img.URI" [alt]="img.alt | translate" class="orcid-icon" />
66
<span>{{ orcidId }}</span>
77
</a>
88
</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.orcid-icon {
2+
height: var(--ds-orcid-icon-height, 16px);
3+
margin-right: 8px;
4+
}

src/app/item-page/simple/field-components/specific-field/orcid/item-page-orcid-field.component.spec.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import {
55
} from '@angular/core/testing';
66
import { TranslateModule } from '@ngx-translate/core';
77
import { of } from 'rxjs';
8+
import { APP_CONFIG } from 'src/config/app-config.interface';
89

910
import { BrowseService } from '../../../../../core/browse/browse.service';
1011
import { BrowseDefinitionDataService } from '../../../../../core/browse/browse-definition-data.service';
1112
import { ConfigurationDataService } from '../../../../../core/data/configuration-data.service';
1213
import { ConfigurationProperty } from '../../../../../core/shared/configuration-property.model';
1314
import { Item } from '../../../../../core/shared/item.model';
1415
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
15-
import { APP_CONFIG } from 'src/config/app-config.interface';
1616
import { ItemPageOrcidFieldComponent } from './item-page-orcid-field.component';
1717

1818
describe('ItemPageOrcidFieldComponent', () => {
@@ -102,6 +102,17 @@ describe('ItemPageOrcidFieldComponent', () => {
102102
expect(component.hasOrcid()).toBe(false);
103103
});
104104

105+
it('should set hasOrcidMetadata property on init', () => {
106+
fixture.detectChanges();
107+
expect(component.hasOrcidMetadata).toBe(true);
108+
});
109+
110+
it('should set hasOrcidMetadata to false when item has no ORCID', () => {
111+
component.item = Object.assign(new Item(), { metadata: {} });
112+
component.ngOnInit();
113+
expect(component.hasOrcidMetadata).toBe(false);
114+
});
115+
105116
it('should construct ORCID URL on init', (done) => {
106117
fixture.detectChanges();
107118

@@ -111,13 +122,9 @@ describe('ItemPageOrcidFieldComponent', () => {
111122
});
112123
});
113124

114-
it('should extract ORCID ID on init', (done) => {
125+
it('should extract ORCID ID on init', () => {
115126
fixture.detectChanges();
116-
117-
component.orcidId$.subscribe(id => {
118-
expect(id).toBe('0000-0002-1825-0097');
119-
done();
120-
});
127+
expect(component.orcidId).toBe('0000-0002-1825-0097');
121128
});
122129

123130
it('should handle ORCID with leading slash', (done) => {
@@ -138,6 +145,8 @@ describe('ItemPageOrcidFieldComponent', () => {
138145
component.ngOnInit();
139146
fixture.detectChanges();
140147

148+
expect(component.orcidId).toBe('0000-0002-1825-0097');
149+
141150
component.orcidUrl$.subscribe(url => {
142151
expect(url).toBe('https://sandbox.orcid.org/0000-0002-1825-0097');
143152
done();
@@ -149,6 +158,8 @@ describe('ItemPageOrcidFieldComponent', () => {
149158
component.ngOnInit();
150159
fixture.detectChanges();
151160

161+
expect(component.orcidId).toBeNull();
162+
152163
component.orcidUrl$.subscribe(url => {
153164
expect(url).toBeNull();
154165
done();

src/app/item-page/simple/field-components/specific-field/orcid/item-page-orcid-field.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ItemPageFieldComponent } from '../item-page-field.component';
2424
@Component({
2525
selector: 'ds-item-page-orcid-field',
2626
templateUrl: './item-page-orcid-field.component.html',
27+
styleUrls: ['./item-page-orcid-field.component.scss'],
2728
standalone: true,
2829
imports: [
2930
AsyncPipe,

0 commit comments

Comments
 (0)