Skip to content

Commit 3d29fb9

Browse files
authored
sed 's/markdownSummary/summary/g'
1 parent 91b7bf9 commit 3d29fb9

File tree

3 files changed

+77
-83
lines changed

3 files changed

+77
-83
lines changed

packages/core/__tests__/markdown-summary.test.ts renamed to packages/core/__tests__/summary.test.ts

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as fs from 'fs'
22
import * as os from 'os'
33
import path from 'path'
4-
import {markdownSummary, SUMMARY_ENV_VAR} from '../src/markdown-summary'
4+
import {summary, SUMMARY_ENV_VAR} from '../src/summary'
55

6-
const testFilePath = path.join(__dirname, 'test', 'test-summary.md')
6+
const testDirectoryPath = path.join(__dirname, 'test')
7+
const testFilePath = path.join(testDirectoryPath, 'test-summary.md')
78

89
async function assertSummary(expected: string): Promise<void> {
910
const file = await fs.promises.readFile(testFilePath, {encoding: 'utf8'})
@@ -67,11 +68,12 @@ const fixtures = {
6768
}
6869
}
6970

70-
describe('@actions/core/src/markdown-summary', () => {
71+
describe('@actions/core/src/summary', () => {
7172
beforeEach(async () => {
7273
process.env[SUMMARY_ENV_VAR] = testFilePath
74+
await fs.promises.mkdir(testDirectoryPath, {recursive: true})
7375
await fs.promises.writeFile(testFilePath, '', {encoding: 'utf8'})
74-
markdownSummary.emptyBuffer()
76+
summary.emptyBuffer()
7577
})
7678

7779
afterAll(async () => {
@@ -80,39 +82,39 @@ describe('@actions/core/src/markdown-summary', () => {
8082

8183
it('throws if summary env var is undefined', async () => {
8284
process.env[SUMMARY_ENV_VAR] = undefined
83-
const write = markdownSummary.addRaw(fixtures.text).write()
85+
const write = summary.addRaw(fixtures.text).write()
8486

8587
await expect(write).rejects.toThrow()
8688
})
8789

8890
it('throws if summary file does not exist', async () => {
8991
await fs.promises.unlink(testFilePath)
90-
const write = markdownSummary.addRaw(fixtures.text).write()
92+
const write = summary.addRaw(fixtures.text).write()
9193

9294
await expect(write).rejects.toThrow()
9395
})
9496

9597
it('appends text to summary file', async () => {
9698
await fs.promises.writeFile(testFilePath, '# ', {encoding: 'utf8'})
97-
await markdownSummary.addRaw(fixtures.text).write()
99+
await summary.addRaw(fixtures.text).write()
98100
await assertSummary(`# ${fixtures.text}`)
99101
})
100102

101103
it('overwrites text to summary file', async () => {
102104
await fs.promises.writeFile(testFilePath, 'overwrite', {encoding: 'utf8'})
103-
await markdownSummary.addRaw(fixtures.text).write({overwrite: true})
105+
await summary.addRaw(fixtures.text).write({overwrite: true})
104106
await assertSummary(fixtures.text)
105107
})
106108

107109
it('appends text with EOL to summary file', async () => {
108110
await fs.promises.writeFile(testFilePath, '# ', {encoding: 'utf8'})
109-
await markdownSummary.addRaw(fixtures.text, true).write()
111+
await summary.addRaw(fixtures.text, true).write()
110112
await assertSummary(`# ${fixtures.text}${os.EOL}`)
111113
})
112114

113115
it('chains appends text to summary file', async () => {
114116
await fs.promises.writeFile(testFilePath, '', {encoding: 'utf8'})
115-
await markdownSummary
117+
await summary
116118
.addRaw(fixtures.text)
117119
.addRaw(fixtures.text)
118120
.addRaw(fixtures.text)
@@ -122,93 +124,93 @@ describe('@actions/core/src/markdown-summary', () => {
122124

123125
it('empties buffer after write', async () => {
124126
await fs.promises.writeFile(testFilePath, '', {encoding: 'utf8'})
125-
await markdownSummary.addRaw(fixtures.text).write()
127+
await summary.addRaw(fixtures.text).write()
126128
await assertSummary(fixtures.text)
127-
expect(markdownSummary.isEmptyBuffer()).toBe(true)
129+
expect(summary.isEmptyBuffer()).toBe(true)
128130
})
129131

130132
it('returns summary buffer as string', () => {
131-
markdownSummary.addRaw(fixtures.text)
132-
expect(markdownSummary.stringify()).toEqual(fixtures.text)
133+
summary.addRaw(fixtures.text)
134+
expect(summary.stringify()).toEqual(fixtures.text)
133135
})
134136

135137
it('return correct values for isEmptyBuffer', () => {
136-
markdownSummary.addRaw(fixtures.text)
137-
expect(markdownSummary.isEmptyBuffer()).toBe(false)
138+
summary.addRaw(fixtures.text)
139+
expect(summary.isEmptyBuffer()).toBe(false)
138140

139-
markdownSummary.emptyBuffer()
140-
expect(markdownSummary.isEmptyBuffer()).toBe(true)
141+
summary.emptyBuffer()
142+
expect(summary.isEmptyBuffer()).toBe(true)
141143
})
142144

143145
it('clears a buffer and summary file', async () => {
144146
await fs.promises.writeFile(testFilePath, 'content', {encoding: 'utf8'})
145-
await markdownSummary.clear()
147+
await summary.clear()
146148
await assertSummary('')
147-
expect(markdownSummary.isEmptyBuffer()).toBe(true)
149+
expect(summary.isEmptyBuffer()).toBe(true)
148150
})
149151

150152
it('adds EOL', async () => {
151-
await markdownSummary
153+
await summary
152154
.addRaw(fixtures.text)
153155
.addEOL()
154156
.write()
155157
await assertSummary(fixtures.text + os.EOL)
156158
})
157159

158160
it('adds a code block without language', async () => {
159-
await markdownSummary.addCodeBlock(fixtures.code).write()
161+
await summary.addCodeBlock(fixtures.code).write()
160162
const expected = `<pre><code>func fork() {\n for {\n go fork()\n }\n}</code></pre>${os.EOL}`
161163
await assertSummary(expected)
162164
})
163165

164166
it('adds a code block with a language', async () => {
165-
await markdownSummary.addCodeBlock(fixtures.code, 'go').write()
167+
await summary.addCodeBlock(fixtures.code, 'go').write()
166168
const expected = `<pre lang="go"><code>func fork() {\n for {\n go fork()\n }\n}</code></pre>${os.EOL}`
167169
await assertSummary(expected)
168170
})
169171

170172
it('adds an unordered list', async () => {
171-
await markdownSummary.addList(fixtures.list).write()
173+
await summary.addList(fixtures.list).write()
172174
const expected = `<ul><li>foo</li><li>bar</li><li>baz</li><li>💣</li></ul>${os.EOL}`
173175
await assertSummary(expected)
174176
})
175177

176178
it('adds an ordered list', async () => {
177-
await markdownSummary.addList(fixtures.list, true).write()
179+
await summary.addList(fixtures.list, true).write()
178180
const expected = `<ol><li>foo</li><li>bar</li><li>baz</li><li>💣</li></ol>${os.EOL}`
179181
await assertSummary(expected)
180182
})
181183

182184
it('adds a table', async () => {
183-
await markdownSummary.addTable(fixtures.table).write()
185+
await summary.addTable(fixtures.table).write()
184186
const expected = `<table><tr><th>foo</th><th>bar</th><th>baz</th><td rowspan="3">tall</td></tr><tr><td>one</td><td>two</td><td>three</td></tr><tr><td colspan="3">wide</td></tr></table>${os.EOL}`
185187
await assertSummary(expected)
186188
})
187189

188190
it('adds a details element', async () => {
189-
await markdownSummary
191+
await summary
190192
.addDetails(fixtures.details.label, fixtures.details.content)
191193
.write()
192194
const expected = `<details><summary>open me</summary>🎉 surprise</details>${os.EOL}`
193195
await assertSummary(expected)
194196
})
195197

196198
it('adds an image with alt text', async () => {
197-
await markdownSummary.addImage(fixtures.img.src, fixtures.img.alt).write()
199+
await summary.addImage(fixtures.img.src, fixtures.img.alt).write()
198200
const expected = `<img src="https://github.com/actions.png" alt="actions logo">${os.EOL}`
199201
await assertSummary(expected)
200202
})
201203

202204
it('adds an image with custom dimensions', async () => {
203-
await markdownSummary
205+
await summary
204206
.addImage(fixtures.img.src, fixtures.img.alt, fixtures.img.options)
205207
.write()
206208
const expected = `<img src="https://github.com/actions.png" alt="actions logo" width="32" height="32">${os.EOL}`
207209
await assertSummary(expected)
208210
})
209211

210212
it('adds an image with custom dimensions', async () => {
211-
await markdownSummary
213+
await summary
212214
.addImage(fixtures.img.src, fixtures.img.alt, fixtures.img.options)
213215
.write()
214216
const expected = `<img src="https://github.com/actions.png" alt="actions logo" width="32" height="32">${os.EOL}`
@@ -217,21 +219,21 @@ describe('@actions/core/src/markdown-summary', () => {
217219

218220
it('adds headings h1...h6', async () => {
219221
for (const i of [1, 2, 3, 4, 5, 6]) {
220-
markdownSummary.addHeading('heading', i)
222+
summary.addHeading('heading', i)
221223
}
222-
await markdownSummary.write()
224+
await summary.write()
223225
const expected = `<h1>heading</h1>${os.EOL}<h2>heading</h2>${os.EOL}<h3>heading</h3>${os.EOL}<h4>heading</h4>${os.EOL}<h5>heading</h5>${os.EOL}<h6>heading</h6>${os.EOL}`
224226
await assertSummary(expected)
225227
})
226228

227229
it('adds h1 if heading level not specified', async () => {
228-
await markdownSummary.addHeading('heading').write()
230+
await summary.addHeading('heading').write()
229231
const expected = `<h1>heading</h1>${os.EOL}`
230232
await assertSummary(expected)
231233
})
232234

233235
it('uses h1 if heading level is garbage or out of range', async () => {
234-
await markdownSummary
236+
await summary
235237
.addHeading('heading', 'foobar')
236238
.addHeading('heading', 1337)
237239
.addHeading('heading', -1)
@@ -242,35 +244,31 @@ describe('@actions/core/src/markdown-summary', () => {
242244
})
243245

244246
it('adds a separator', async () => {
245-
await markdownSummary.addSeparator().write()
247+
await summary.addSeparator().write()
246248
const expected = `<hr>${os.EOL}`
247249
await assertSummary(expected)
248250
})
249251

250252
it('adds a break', async () => {
251-
await markdownSummary.addBreak().write()
253+
await summary.addBreak().write()
252254
const expected = `<br>${os.EOL}`
253255
await assertSummary(expected)
254256
})
255257

256258
it('adds a quote', async () => {
257-
await markdownSummary.addQuote(fixtures.quote.text).write()
259+
await summary.addQuote(fixtures.quote.text).write()
258260
const expected = `<blockquote>Where the world builds software</blockquote>${os.EOL}`
259261
await assertSummary(expected)
260262
})
261263

262264
it('adds a quote with citation', async () => {
263-
await markdownSummary
264-
.addQuote(fixtures.quote.text, fixtures.quote.cite)
265-
.write()
265+
await summary.addQuote(fixtures.quote.text, fixtures.quote.cite).write()
266266
const expected = `<blockquote cite="https://github.com/about">Where the world builds software</blockquote>${os.EOL}`
267267
await assertSummary(expected)
268268
})
269269

270270
it('adds a link with href', async () => {
271-
await markdownSummary
272-
.addLink(fixtures.link.text, fixtures.link.href)
273-
.write()
271+
await summary.addLink(fixtures.link.text, fixtures.link.href).write()
274272
const expected = `<a href="https://github.com/">GitHub</a>${os.EOL}`
275273
await assertSummary(expected)
276274
})

packages/core/src/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,6 @@ export async function getIDToken(aud?: string): Promise<string> {
361361
}
362362

363363
/**
364-
* Markdown summary exports
364+
* Summary exports
365365
*/
366-
export {markdownSummary} from './markdown-summary'
366+
export {summary} from './summary'

0 commit comments

Comments
 (0)