File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -24,16 +24,16 @@ export const constructNewContents = (
2424
2525 for ( const [ category , category_info ] of categories_map ) {
2626 const content = [
27- `<h3><img height="20px" src="https://img.shields.io/badge/${ category } - ${
28- ColorMap [ category_info . color ]
29- } "/></h3>`
27+ `<h3><img height="20px" src="https://img.shields.io/badge/${ qs . escape (
28+ category
29+ ) } - ${ ColorMap [ category_info . color ] } "/></h3>`
3030 ] ;
3131 category_info . items . forEach ( ( item ) =>
3232 content . push (
3333 `<span><img src="https://img.shields.io/badge/-${ qs . escape (
3434 item . title [ 0 ] [ 0 ]
3535 ) } -${
36- item [ color_schema_unit_key ] [ 0 ] [ 0 ]
36+ item [ color_schema_unit_key ] ?. [ 0 ] [ 0 ] ?? 'black'
3737 } ?style=flat-square&logo=${ qs . escape ( item . title [ 0 ] [ 0 ] ) } " alt="${
3838 item . title [ 0 ] [ 0 ]
3939 } "/></span>`
Original file line number Diff line number Diff line change 1+ import { constructNewContents } from '../../src/utils/constructNewContents' ;
2+
3+ it ( 'Should Work' , ( ) => {
4+ const categories_map = new Map ( [
5+ [
6+ 'Tech Tools' ,
7+ {
8+ items : [
9+ {
10+ title : [ [ 'React' ] ] ,
11+ color : [ [ 'blue' ] ]
12+ } ,
13+ {
14+ title : [ [ 'Apollo Graphql' ] ]
15+ }
16+ ] ,
17+ color : 'teal'
18+ }
19+ ]
20+ ] ) as any ;
21+
22+ const new_contents = constructNewContents ( categories_map , 'color' ) ;
23+ expect ( new_contents ) . toStrictEqual ( [
24+ '<h3><img height="20px" src="https://img.shields.io/badge/Tech%20Tools-467870"/></h3>' ,
25+ '<span><img src="https://img.shields.io/badge/-React-blue?style=flat-square&logo=React" alt="React"/></span>' ,
26+ '<span><img src="https://img.shields.io/badge/-Apollo%20Graphql-black?style=flat-square&logo=Apollo%20Graphql" alt="Apollo Graphql"/></span>' ,
27+ '<hr>'
28+ ] ) ;
29+ } ) ;
You can’t perform that action at this time.
0 commit comments