generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
50 lines (43 loc) · 1.83 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
const checkExistence = require('./check-existence');
test('blank files do not count', async () => {
const {isPresent,message} = await checkExistence('emptyfile.js');
console.log(message);
expect(isPresent).toBe(false);
expect(message).toBe('emptyfile.js exists with no content. Please finish file contents before proceeding.')
});
test('false if file does not exist', async () => {
const {isPresent,message} = await checkExistence('abc');
console.log(message);
expect(isPresent).toBe(false);
expect(message).toBe('Error finding abc. Please ensure file exists and is in the correct location.')
});
test('look for file', async () => {
const {isPresent,message} = await checkExistence('.github/dependabot.yml');
console.log(message);
expect(isPresent).toBe(true);
expect(message).toBe('.github/dependabot.yml exists');
});
test('look for codeowner global owner', async () => {
const {isPresent,message} = await checkExistence('.github/CODEOWNERS');
console.log(message);
expect(isPresent).toBe(true);
expect(message).toBe('.github/CODEOWNERS exists');
});
test('fail if no codeowner global owner', async () => {
const {isPresent,message} = await checkExistence('.github/CODEOWNERS-bad');
console.log(message);
expect(isPresent).toBe(false);
expect(message).toBe('There is no global owner in .github/CODEOWNERS-bad. Please add one before proceeding.');
});
test('find file without extension', async () => {
const {isPresent,message} = await checkExistence('README');
console.log(message);
expect(isPresent).toBe(true);
expect(message).toBe('README exists');
});
test('error on no file without extension', async () => {
const {isPresent,message} = await checkExistence('abc');
console.log(message);
expect(isPresent).toBe(false);
expect(message).toBe('Error finding abc. Please ensure file exists and is in the correct location.');
});