@@ -13,16 +13,17 @@ vi.mock("../../readFileSafe.js", () => ({
13
13
describe ( "readDefaultsFromReadme" , ( ) => {
14
14
describe ( "logo" , ( ) => {
15
15
it ( "defaults to undefined when it cannot be found" , async ( ) => {
16
- mockReadFileSafe . mockResolvedValue ( "nothing." ) ;
16
+ mockReadFileSafe . mockResolvedValue ( `
17
+ nothing.
18
+ ` ) ;
17
19
18
20
const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
19
21
20
22
expect ( logo ) . toBeUndefined ( ) ;
21
23
} ) ;
22
24
23
- it ( "parses when found after a badge image " , async ( ) => {
25
+ it ( "parses when found in an unquoted string " , async ( ) => {
24
26
mockReadFileSafe . mockResolvedValue ( `
25
- <a href="#contributors" target="_blank"><img alt="👪 All Contributors: 48" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-48-21bb42.svg" /></a>
26
27
<img src=abc/def.jpg/>
27
28
` ) ;
28
29
@@ -34,8 +35,10 @@ describe("readDefaultsFromReadme", () => {
34
35
} ) ;
35
36
} ) ;
36
37
37
- it ( "parses when found in an unquoted string" , async ( ) => {
38
- mockReadFileSafe . mockResolvedValue ( "<img src=abc/def.jpg/>" ) ;
38
+ it ( "parses when found in a single quoted string" , async ( ) => {
39
+ mockReadFileSafe . mockResolvedValue ( `
40
+ <img src='abc/def.jpg'/>
41
+ ` ) ;
39
42
40
43
const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
41
44
@@ -45,8 +48,10 @@ describe("readDefaultsFromReadme", () => {
45
48
} ) ;
46
49
} ) ;
47
50
48
- it ( "parses when found in a single quoted string" , async ( ) => {
49
- mockReadFileSafe . mockResolvedValue ( "<img src='abc/def.jpg'/>" ) ;
51
+ it ( "parses when found in a double quoted string" , async ( ) => {
52
+ mockReadFileSafe . mockResolvedValue ( `
53
+ <img src="abc/def.jpg"/>
54
+ ` ) ;
50
55
51
56
const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
52
57
@@ -56,21 +61,23 @@ describe("readDefaultsFromReadme", () => {
56
61
} ) ;
57
62
} ) ;
58
63
59
- it ( "parses when found in a double quoted string" , async ( ) => {
60
- mockReadFileSafe . mockResolvedValue ( '<img src="abc/def.jpg"/>' ) ;
64
+ it ( "includes alt text when it exists in double quotes" , async ( ) => {
65
+ mockReadFileSafe . mockResolvedValue ( `
66
+ <img alt="Project logo: a fancy circle" src="abc/def.jpg"/>
67
+ ` ) ;
61
68
62
69
const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
63
70
64
71
expect ( logo ) . toEqual ( {
65
- alt : "Project logo" ,
72
+ alt : "Project logo: a fancy circle " ,
66
73
src : "abc/def.jpg" ,
67
74
} ) ;
68
75
} ) ;
69
76
70
- it ( "includes alt text when it exists in double quotes" , async ( ) => {
71
- mockReadFileSafe . mockResolvedValue (
72
- ' <img alt=" Project logo: a fancy circle" src=" abc/def.jpg"/>' ,
73
- ) ;
77
+ it ( "includes alt text when it exists in single quotes" , async ( ) => {
78
+ mockReadFileSafe . mockResolvedValue ( `
79
+ <img alt=' Project logo: a fancy circle' src=' abc/def.jpg'/> ,
80
+ ` ) ;
74
81
75
82
const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
76
83
@@ -80,31 +87,63 @@ describe("readDefaultsFromReadme", () => {
80
87
} ) ;
81
88
} ) ;
82
89
83
- it ( "includes alt text when it exists in single quotes" , async ( ) => {
84
- mockReadFileSafe . mockResolvedValue (
85
- "<img alt='Project logo: a fancy circle' src='abc/def.jpg'/>" ,
86
- ) ;
90
+ it ( "parses when found after a badge image" , async ( ) => {
91
+ mockReadFileSafe . mockResolvedValue ( `
92
+ <a href="#contributors" target="_blank"><img alt="👪 All Contributors: 48" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-48-21bb42.svg" /></a>
93
+ <img src=abc/def.jpg/>
94
+ ` ) ;
87
95
88
96
const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
89
97
90
98
expect ( logo ) . toEqual ( {
91
- alt : "Project logo: a fancy circle " ,
99
+ alt : "Project logo" ,
92
100
src : "abc/def.jpg" ,
93
101
} ) ;
94
102
} ) ;
103
+
104
+ it ( "parses when found after an h1 and many badge images" , async ( ) => {
105
+ mockReadFileSafe . mockResolvedValue ( `<h1 align="center">Create TypeScript App</h1>
106
+
107
+ <p align="center">Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 💝</p>
108
+
109
+ <p align="center">
110
+ <!-- prettier-ignore-start -->
111
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
112
+ <a href="#contributors" target="_blank"><img alt="👪 All Contributors: 48" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-48-21bb42.svg" /></a>
113
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
114
+ <!-- prettier-ignore-end -->
115
+ <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="🤝 Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
116
+ <a href="https://codecov.io/gh/JoshuaKGoldberg/create-typescript-app" target="_blank"><img alt="🧪 Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/create-typescript-app?label=%F0%9F%A7%AA%20coverage" /></a>
117
+ <a href="https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/LICENSE.md" target="_blank"><img alt="📝 License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg"></a>
118
+ <a href="http://npmjs.com/package/create-typescript-app"><img alt="📦 npm version" src="https://img.shields.io/npm/v/create-typescript-app?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
119
+ <img alt="💪 TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
120
+ </p>
121
+
122
+ <img align="right" alt="Project logo: the TypeScript blue square with rounded corners, but a plus sign instead of 'TS'" src="./docs/create-typescript-app.png">
123
+ ` ) ;
124
+
125
+ const logo = await readDefaultsFromReadme ( ) . logo ( ) ;
126
+
127
+ expect ( logo ) . toEqual ( {
128
+ alt : "Project logo: the TypeScript blue square with rounded corners, but a plus sign instead of 'TS'" ,
129
+ src : "./docs/create-typescript-app.png" ,
130
+ } ) ;
131
+ } ) ;
95
132
} ) ;
96
133
97
134
describe ( "title" , ( ) => {
98
135
it ( "defaults to undefined when it cannot be found" , async ( ) => {
99
- mockReadFileSafe . mockResolvedValue ( "nothing." ) ;
136
+ mockReadFileSafe . mockResolvedValue ( `
137
+ nothing.
138
+ ` ) ;
100
139
101
140
const title = await readDefaultsFromReadme ( ) . title ( ) ;
102
141
103
142
expect ( title ) . toBeUndefined ( ) ;
104
143
} ) ;
105
144
106
145
it ( 'reads title as markdown from "README.md" when it exists' , async ( ) => {
107
- mockReadFileSafe . mockResolvedValue ( " # My Awesome Package" ) ;
146
+ mockReadFileSafe . mockResolvedValue ( ` # My Awesome Package` ) ;
108
147
109
148
const title = await readDefaultsFromReadme ( ) . title ( ) ;
110
149
@@ -122,7 +161,7 @@ describe("readDefaultsFromReadme", () => {
122
161
} ) ;
123
162
124
163
it ( "returns undefined when title does not exist" , async ( ) => {
125
- mockReadFileSafe . mockResolvedValue ( "" ) ;
164
+ mockReadFileSafe . mockResolvedValue ( `Other text.` ) ;
126
165
127
166
const title = await readDefaultsFromReadme ( ) . title ( ) ;
128
167
0 commit comments