forked from FranzDiebold/github-env-vars-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
71 lines (56 loc) · 1.98 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
70
71
const {
slugify, getRepositoryOwner, getRepositoryName, getRefName, getShaShort,
} = require('./index');
test('slugifies text', () => {
expect(slugify(' /abc+efg*123/test§xyz ')).toEqual('abc-efg-123-test-xyz');
});
test('slugifies a text to a maximum length', () => {
expect(slugify(' /abc+efg*123/test§xyz 1234567 /(ö) ', 16))
.toEqual('abc-efg-123-test');
});
test('slugifies a text to a maximum length with trailing dash', () => {
expect(slugify(' /abc+efg*123/test§xyz 1234567 /(ö) ', 17))
.toEqual('abc-efg-123-test');
});
test('slugifies ref name with dash', () => {
expect(slugify('feat/feature-branch-1')).toEqual('feat-feature-branch-1');
});
test('slugifies empty text', () => {
expect(slugify('')).toEqual('');
});
test('gets repository owner', () => {
expect(getRepositoryOwner('FranzDiebold/github-env-vars-action'))
.toEqual('FranzDiebold');
});
test('gets repository owner for empty repository', () => {
expect(getRepositoryOwner(undefined)).toBeFalsy();
});
test('gets repository name from repository', () => {
expect(getRepositoryName('FranzDiebold/github-env-vars-action'))
.toEqual('github-env-vars-action');
});
test('gets repository name for empty repository', () => {
expect(getRepositoryName(undefined)).toBeFalsy();
});
test('gets ref name from simple ref', () => {
expect(getRefName('refs/heads/feature-branch-1'))
.toEqual('feature-branch-1');
});
test('gets ref name from tag', () => {
expect(getRefName('refs/tags/v1.3.7'))
.toEqual('v1.3.7');
});
test('gets ref name from complex ref', () => {
expect(getRefName('refs/heads/feat/feature-branch-1'))
.toEqual('feat/feature-branch-1');
});
test('gets ref name for empty ref', () => {
expect(getRefName(undefined)).toBeFalsy();
});
test('gets short SHA', () => {
expect(getShaShort('ffac537e6cbbf934b08745a378932722df287a53'))
.toEqual('ffac537e');
});
test('gets short SHA for empty SHA', () => {
expect(getShaShort(undefined)).toBeFalsy();
});