@@ -507,6 +507,113 @@ describe('RestClient', () => {
507507 } ) ;
508508 } ) ;
509509 } ) ;
510+
511+ describe ( '.corporateActions' , ( ) => {
512+ it ( 'should contain stock corporate actions api endpoints' , ( ) => {
513+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
514+ const stock = client . stock as RestStockClient ;
515+ expect ( stock . corporateActions ) . toBeDefined ( ) ;
516+ expect ( stock . corporateActions ) . toHaveProperty ( 'capitalChanges' ) ;
517+ expect ( stock . corporateActions ) . toHaveProperty ( 'dividends' ) ;
518+ expect ( stock . corporateActions ) . toHaveProperty ( 'listingApplicants' ) ;
519+ } ) ;
520+
521+ describe ( '.capitalChanges()' , ( ) => {
522+ it ( 'should request with api key' , async ( ) => {
523+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
524+ const stock = client . stock as RestStockClient ;
525+ await stock . corporateActions . capitalChanges ( { start_date : '2025-01-01' , end_date : '2025-12-31' , sort : 'asc' } ) ;
526+ expect ( fetch ) . toBeCalledWith (
527+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/capital-changes?end_date=2025-12-31&sort=asc&start_date=2025-01-01' ,
528+ { headers : { 'X-API-KEY' : 'api-key' } } ,
529+ ) ;
530+ } ) ;
531+
532+ it ( 'should request with bearer token' , async ( ) => {
533+ const client = new RestClient ( { bearerToken : 'bearer-token' } ) ;
534+ const stock = client . stock as RestStockClient ;
535+ await stock . corporateActions . capitalChanges ( { start_date : '2025-01-01' , end_date : '2025-12-31' , sort : 'asc' } ) ;
536+ expect ( fetch ) . toBeCalledWith (
537+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/capital-changes?end_date=2025-12-31&sort=asc&start_date=2025-01-01' ,
538+ { headers : { 'Authorization' : 'Bearer bearer-token' } } ,
539+ ) ;
540+ } ) ;
541+
542+ it ( 'should request without params' , async ( ) => {
543+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
544+ const stock = client . stock as RestStockClient ;
545+ await stock . corporateActions . capitalChanges ( ) ;
546+ expect ( fetch ) . toBeCalledWith (
547+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/capital-changes' ,
548+ { headers : { 'X-API-KEY' : 'api-key' } } ,
549+ ) ;
550+ } ) ;
551+ } ) ;
552+
553+ describe ( '.dividends()' , ( ) => {
554+ it ( 'should request with api key' , async ( ) => {
555+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
556+ const stock = client . stock as RestStockClient ;
557+ await stock . corporateActions . dividends ( { start_date : '2025-01-01' , end_date : '2025-12-31' , sort : 'desc' } ) ;
558+ expect ( fetch ) . toBeCalledWith (
559+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/dividends?end_date=2025-12-31&sort=desc&start_date=2025-01-01' ,
560+ { headers : { 'X-API-KEY' : 'api-key' } } ,
561+ ) ;
562+ } ) ;
563+
564+ it ( 'should request with bearer token' , async ( ) => {
565+ const client = new RestClient ( { bearerToken : 'bearer-token' } ) ;
566+ const stock = client . stock as RestStockClient ;
567+ await stock . corporateActions . dividends ( { start_date : '2025-01-01' , end_date : '2025-12-31' , sort : 'desc' } ) ;
568+ expect ( fetch ) . toBeCalledWith (
569+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/dividends?end_date=2025-12-31&sort=desc&start_date=2025-01-01' ,
570+ { headers : { 'Authorization' : 'Bearer bearer-token' } } ,
571+ ) ;
572+ } ) ;
573+
574+ it ( 'should request without params' , async ( ) => {
575+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
576+ const stock = client . stock as RestStockClient ;
577+ await stock . corporateActions . dividends ( ) ;
578+ expect ( fetch ) . toBeCalledWith (
579+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/dividends' ,
580+ { headers : { 'X-API-KEY' : 'api-key' } } ,
581+ ) ;
582+ } ) ;
583+ } ) ;
584+
585+ describe ( '.listingApplicants()' , ( ) => {
586+ it ( 'should request with api key' , async ( ) => {
587+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
588+ const stock = client . stock as RestStockClient ;
589+ await stock . corporateActions . listingApplicants ( { start_date : '2025-01-01' , end_date : '2025-12-31' , sort : 'asc' } ) ;
590+ expect ( fetch ) . toBeCalledWith (
591+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/listing-applicants?end_date=2025-12-31&sort=asc&start_date=2025-01-01' ,
592+ { headers : { 'X-API-KEY' : 'api-key' } } ,
593+ ) ;
594+ } ) ;
595+
596+ it ( 'should request with bearer token' , async ( ) => {
597+ const client = new RestClient ( { bearerToken : 'bearer-token' } ) ;
598+ const stock = client . stock as RestStockClient ;
599+ await stock . corporateActions . listingApplicants ( { start_date : '2025-01-01' , end_date : '2025-12-31' , sort : 'asc' } ) ;
600+ expect ( fetch ) . toBeCalledWith (
601+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/listing-applicants?end_date=2025-12-31&sort=asc&start_date=2025-01-01' ,
602+ { headers : { 'Authorization' : 'Bearer bearer-token' } } ,
603+ ) ;
604+ } ) ;
605+
606+ it ( 'should request without params' , async ( ) => {
607+ const client = new RestClient ( { apiKey : 'api-key' } ) ;
608+ const stock = client . stock as RestStockClient ;
609+ await stock . corporateActions . listingApplicants ( ) ;
610+ expect ( fetch ) . toBeCalledWith (
611+ 'https://api.fugle.tw/marketdata/v1.0/stock/corporate-actions/listing-applicants' ,
612+ { headers : { 'X-API-KEY' : 'api-key' } } ,
613+ ) ;
614+ } ) ;
615+ } ) ;
616+ } ) ;
510617 } ) ;
511618
512619 describe ( '.futopt' , ( ) => {
0 commit comments