@@ -14,6 +14,10 @@ const SCENES = {
1414 'spike-jp' : { t : 'finance' , l : 'jp' } ,
1515 'spike-down' : { t : 'finance' , l : 'en' } ,
1616 'spike-cap' : { t : 'finance' , l : 'en' } ,
17+ 'spike-shape' : { t : 'finance' , l : 'en' } ,
18+ 'spike-html' : { t : 'finance' , l : 'en' } ,
19+ 'spike-floor' : { t : 'finance' , l : 'en' } ,
20+ 'spike-noname' : { t : 'finance' , l : 'en' } ,
1721 'lang-es' : { } ,
1822 'lang-ja' : { } ,
1923 'lang-en' : { } ,
@@ -954,35 +958,63 @@ globalThis.fetch = input => {
954958 if ( url . includes ( 'status.cloud.google.com' ) ) return json ( [ ] ) ;
955959 return json ( { incidents : [ ] } ) ;
956960 }
957- if ( url . includes ( 'finance-query.com/v2/screeners/day-gainers' ) ) {
961+ if ( url . includes ( 'finance-query.com/v2/screeners/day-gainers' )
962+ || url . includes ( 'finance-query.com/v2/screeners/day-losers' ) ) {
963+ const gainers = url . includes ( 'day-gainers' ) ;
958964 if ( scenario === 'spike-down' ) return text ( '' , 500 ) ;
959- const gainer = ( symbol , name , pct ) => ( {
965+ if ( scenario === 'spike-html' ) return text ( '<!DOCTYPE html><html>blocked</html>' ) ;
966+ const q = ( symbol , name , pct ) => ( {
960967 symbol, shortName : name , regularMarketChangePercent : pct ,
961968 } ) ;
969+ const empty = json ( { quotes : [ ] } ) ;
962970 if ( scenario === 'spike' || scenario === 'spike-es' || scenario === 'spike-jp' ) {
971+ if ( gainers ) {
972+ return json ( {
973+ quotes : [
974+ q ( 'ROIV' , 'Roivant Sciences Ltd.' , 18.4 ) ,
975+ q ( 'INTC' , 'Intel Corporation' , 8.1 ) ,
976+ ...( scenario === 'spike' ? [ q ( 'CRWV' , 'CoreWeave, Inc.' , 16.1 ) ] : [ ] ) ,
977+ ] ,
978+ } ) ;
979+ }
963980 return json ( {
964981 quotes : [
965- gainer ( 'ROIV' , 'Roivant Sciences Ltd.' , 18.4 ) ,
966- gainer ( 'INTC' , 'Intel Corporation' , 8.1 ) ,
967- ...( scenario === 'spike' ? [ gainer ( 'CRWV' , 'CoreWeave, Inc.' , 16.1 ) ] : [ ] ) ,
982+ q ( 'DYN' , 'Dyne Therapeutics, Inc.' , - 18.9 ) ,
983+ q ( 'NVS' , 'Novartis AG' , - 8 ) ,
968984 ] ,
969985 } ) ;
970986 }
971987 if ( scenario === 'spike-quiet' ) {
972- return json ( { quotes : [ gainer ( 'INTC' , 'Intel Corporation' , 8.1 ) , gainer ( 'AAPL' , 'Apple Inc.' , 14.9 ) ] } ) ;
988+ return json ( {
989+ quotes : gainers
990+ ? [ q ( 'INTC' , 'Intel Corporation' , 8.1 ) , q ( 'AAPL' , 'Apple Inc.' , 14.9 ) ]
991+ : [ q ( 'NVS' , 'Novartis AG' , - 14.9 ) ] ,
992+ } ) ;
973993 }
974994 if ( scenario === 'spike-cap' ) {
995+ if ( ! gainers ) return json ( { quotes : [ q ( 'FFF' , 'Foxtrot' , - 21 ) ] } ) ;
975996 return json ( {
976997 quotes : [
977- gainer ( 'AAA' , 'Alpha' , 16 ) ,
978- gainer ( 'EEE' , 'Echo' , 20 ) ,
979- gainer ( 'CCC' , 'Charlie' , 18 ) ,
980- gainer ( 'DDD' , 'Delta' , 17 ) ,
981- gainer ( 'BBB' , 'Bravo' , 19 ) ,
998+ q ( 'AAA' , 'Alpha' , 16 ) ,
999+ q ( 'EEE' , 'Echo' , 20 ) ,
1000+ q ( 'CCC' , 'Charlie' , 18 ) ,
1001+ q ( 'DDD' , 'Delta' , 17 ) ,
1002+ q ( 'BBB' , 'Bravo' , 19 ) ,
9821003 ] ,
9831004 } ) ;
9841005 }
985- return json ( { quotes : [ ] } ) ;
1006+ if ( scenario === 'spike-shape' ) {
1007+ return gainers ? json ( { data : [ q ( 'ROIV' , 'Roivant Sciences Ltd.' , 18.4 ) ] } ) : json ( { quotes : { symbol : 'DYN' } } ) ;
1008+ }
1009+ if ( scenario === 'spike-floor' ) {
1010+ if ( gainers ) return json ( { quotes : [ q ( 'ROIV' , 'Roivant Sciences Ltd.' , 15 ) , q ( 'AAPL' , 'Apple Inc.' , 14.9 ) ] } ) ;
1011+ return json ( { quotes : [ q ( 'DYN' , 'Dyne Therapeutics, Inc.' , - 15 ) , q ( 'NVS' , 'Novartis AG' , - 14.9 ) ] } ) ;
1012+ }
1013+ if ( scenario === 'spike-noname' ) {
1014+ if ( ! gainers ) return empty ;
1015+ return json ( { quotes : [ { symbol : 'XYZ' , regularMarketChangePercent : 16 } ] } ) ;
1016+ }
1017+ return empty ;
9861018 }
9871019 return Promise . reject ( new Error ( 'unmocked ' + url ) ) ;
9881020} ;
0 commit comments