-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
55 lines (50 loc) · 1.35 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
const action = require('.')
const core = require('@actions/core')
const process = require('process');
const cp = require('child_process');
const path = require('path');
const fs = require('fs')
const git = require('isomorphic-git');
let input
let err
describe('release-please-action', () => {
beforeEach(() => {
input = {}
err = ''
core.getInput = name => {
if (input[name] === undefined || input[name] == null) {
return defaultInput[name]
} else {
return input[name]
}
}
core.setFailed = msg => {
err = msg
}
})
test('test actual commit', async () => {
input = {domains: 'gmail.com'}
git.readCommit = () => {
return { commit: { author: {email: '[email protected]'} } }
}
process.env.GITHUB_SHA = 'f73f44e6a181cc0643fd3cb0717efdf9513e7f0f'
await action.main()
expect(err).toBe('invalid email domain')
});
test('test invalid email domain', async () => {
input = {domains: 'example.com'}
git.readCommit = () => {
return { commit: { author: {email: '[email protected]'} } }
}
await action.main()
expect(err).toBe('invalid email domain')
});
test('test ok', async () => {
input = {domains: 'bar.com'}
git.readCommit = () => {
return { commit: { author: {email: '[email protected]'} } }
}
await action.main()
expect(err).toBe('')
});
})