@@ -5,14 +5,16 @@ import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
55import { DestroyRef } from '@angular/core' ;
66import { ComponentFixture , TestBed } from '@angular/core/testing' ;
77
8+ import { RorFunderOption } from '../../models/ror.model' ;
89import { MetadataSelectors } from '../../store' ;
910
1011import { FundingDialogComponent } from './funding-dialog.component' ;
1112
12- import { MOCK_FUNDERS } from '@testing/mocks/funder.mock' ;
1313import { OSFTestingModule } from '@testing/osf.testing.module' ;
1414import { provideMockStore } from '@testing/providers/store-provider.mock' ;
1515
16+ const MOCK_ROR_FUNDERS : RorFunderOption [ ] = [ { id : 'https://ror.org/0test' , name : 'Test Funder' } ] ;
17+
1618describe ( 'FundingDialogComponent' , ( ) => {
1719 let component : FundingDialogComponent ;
1820 let fixture : ComponentFixture < FundingDialogComponent > ;
@@ -25,7 +27,7 @@ describe('FundingDialogComponent', () => {
2527 MockProvider ( DynamicDialogConfig , { data : { funders : [ ] } } ) ,
2628 provideMockStore ( {
2729 signals : [
28- { selector : MetadataSelectors . getFundersList , value : MOCK_FUNDERS } ,
30+ { selector : MetadataSelectors . getFundersList , value : MOCK_ROR_FUNDERS } ,
2931 { selector : MetadataSelectors . getFundersLoading , value : false } ,
3032 ] ,
3133 } ) ,
@@ -145,6 +147,16 @@ describe('FundingDialogComponent', () => {
145147 expect ( entry . get ( 'funderIdentifierType' ) ?. value ) . toBe ( initialValues . funderIdentifierType ) ;
146148 } ) ;
147149
150+ it ( 'should update funding entry when funder is selected from ROR list' , ( ) => {
151+ const entry = component . fundingEntries . at ( 0 ) ;
152+
153+ component . onFunderSelected ( 'Test Funder' , 0 ) ;
154+
155+ expect ( entry . get ( 'funderName' ) ?. value ) . toBe ( 'Test Funder' ) ;
156+ expect ( entry . get ( 'funderIdentifier' ) ?. value ) . toBe ( 'https://ror.org/0test' ) ;
157+ expect ( entry . get ( 'funderIdentifierType' ) ?. value ) . toBe ( 'ROR ID' ) ;
158+ } ) ;
159+
148160 it ( 'should remove funding entry when more than one exists' , ( ) => {
149161 component . addFundingEntry ( ) ;
150162 expect ( component . fundingEntries . length ) . toBe ( 2 ) ;
0 commit comments