-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
69 lines (50 loc) · 1.89 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const report = require('./report')
const cp = require('child_process')
const github = require('@actions/github')
const core = require('@actions/core')
const replaceComment = require('@aki77/actions-replace-comment')
const path = require('path')
let inputs = {"token":"demo"}
describe('input-helper tests', () => {
beforeAll(() => {
jest.spyOn(github.context, 'repo', 'get').mockImplementation(() => {
return {
owner: 'some-owner',
repo: 'some-repo'
}
})
jest.spyOn(github.context, 'issue', 'get').mockImplementation(() => {
return {
number: 1233,
}
})
github.context.ref = 'refs/heads/some-ref'
github.context.sha = '1234567890123456789012345678901234567890'
jest.spyOn(core, 'getInput').mockImplementation((name) => {
return inputs[name]
})
jest.spyOn(replaceComment, 'default').mockImplementation(jest.fn())
jest.spyOn(core, 'info').mockImplementation(jest.fn(x => console.log(x)))
jest.spyOn(core, 'setFailed').mockImplementation(jest.fn(x => console.log(x)))
})
afterAll(() => {
// Restore GitHub workspace
delete process.env['GITHUB_WORKSPACE']
if (originalGitHubWorkspace) {
process.env['GITHUB_WORKSPACE'] = originalGitHubWorkspace
}
// Restore @actions/github context
github.context.ref = originalContext.ref
github.context.sha = originalContext.sha
// Restore
jest.restoreAllMocks()
})
test('json without group metrics', async () => {
const badgePath = "example/"
const files = [path.resolve('./', 'example/jacoco.csv')]
badgeRelativePath=path.resolve('./', badgePath+"covergeBadge.svg")
console.log(badgeRelativePath)
const success = await report(files,10,badgeRelativePath)
expect(true).toEqual(true)
})
})