Skip to content

Commit 0a188c2

Browse files
committed
get back to 100% test coverage
1 parent 7c020ae commit 0a188c2

7 files changed

Lines changed: 19 additions & 8 deletions

File tree

__tests__/functions/prechecks.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {prechecks} from '../../src/functions/prechecks.js'
2-
import {vi, expect, describe, test, beforeEach, afterEach} from 'vitest'
2+
import {vi, expect, test, beforeEach} from 'vitest'
33
import {COLORS} from '../../src/functions/colors.js'
44
import * as isAdmin from '../../src/functions/admin.js'
55
import * as isOutdated from '../../src/functions/outdated-check.js'

__tests__/functions/string-to-array.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {stringToArray} from '../../src/functions/string-to-array.js'
2-
import {vi, expect, describe, test, beforeEach, afterEach} from 'vitest'
2+
import {vi, expect, test, beforeEach} from 'vitest'
33
import * as core from '@actions/core'
44

55
const debugMock = vi.spyOn(core, 'debug')
6+
const errorMock = vi.spyOn(core, 'error')
67

78
beforeEach(() => {
89
vi.clearAllMocks()
@@ -33,3 +34,9 @@ test('successfully converts an empty string to an empty array', async () => {
3334
test('successfully converts garbage to an empty array', async () => {
3435
expect(stringToArray(',,,')).toStrictEqual([])
3536
})
37+
38+
test('throws an error when string processing fails', async () => {
39+
// Pass a non-string value to trigger the error
40+
expect(() => stringToArray(null)).toThrow('could not convert String to Array')
41+
expect(errorMock).toHaveBeenCalled()
42+
})

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/prechecks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,13 @@ export async function prechecks(context, octokit, data) {
326326
try {
327327
core.debug('raw graphql result for debugging:')
328328
core.debug(result)
329+
/* c8 ignore start */
329330
} catch {
330-
// istanbul ignore next
331331
core.debug(
332332
'Could not output raw graphql result for debugging - This is bad'
333333
)
334334
}
335+
/* c8 ignore stop */
335336
}
336337

337338
// Get admin data

src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ export async function run() {
860860
}
861861
}
862862

863-
/* istanbul ignore next */
863+
/* c8 ignore start */
864864
if (core.getState('isPost') === 'true') {
865865
post()
866866
} else {
@@ -871,3 +871,4 @@ if (core.getState('isPost') === 'true') {
871871
run()
872872
}
873873
}
874+
/* c8 ignore stop */

0 commit comments

Comments
 (0)