mirror of
https://github.com/FranzDiebold/github-env-vars-action.git
synced 2025-04-21 15:57:32 -05:00
Add tests and CI.
This commit is contained in:
parent
a1deed7ade
commit
932bbbde38
11 changed files with 5392 additions and 84 deletions
44
index.test.js
Normal file
44
index.test.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
const {
|
||||
getRepositoryOwner, getRepositoryName, getRefName, getShaShort,
|
||||
} = require('./index');
|
||||
|
||||
test('gets repository owner', () => {
|
||||
expect(getRepositoryOwner('FranzDiebold/github-env-vars-action'))
|
||||
.toEqual('FranzDiebold');
|
||||
});
|
||||
|
||||
test('gets repository owner for empty GITHUB_REPOSITORY', () => {
|
||||
expect(getRepositoryOwner(undefined)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('gets repository name', () => {
|
||||
expect(getRepositoryName('FranzDiebold/github-env-vars-action'))
|
||||
.toEqual('github-env-vars-action');
|
||||
});
|
||||
|
||||
test('gets repository name for empty GITHUB_REPOSITORY', () => {
|
||||
expect(getRepositoryName(undefined)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('gets ref from simple ref name', () => {
|
||||
expect(getRefName('refs/heads/feature-branch-1'))
|
||||
.toEqual('feature-branch-1');
|
||||
});
|
||||
|
||||
test('gets ref from complex ref name', () => {
|
||||
expect(getRefName('refs/heads/feat/feature-branch-1'))
|
||||
.toEqual('feat/feature-branch-1');
|
||||
});
|
||||
|
||||
test('gets repository name for empty GITHUB_REF_NAME', () => {
|
||||
expect(getRefName(undefined)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('gets short SHA', () => {
|
||||
expect(getShaShort('ffac537e6cbbf934b08745a378932722df287a53'))
|
||||
.toEqual('ffac537e');
|
||||
});
|
||||
|
||||
test('gets short SHA for empty GITHUB_SHA', () => {
|
||||
expect(getShaShort(undefined)).toBeFalsy();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue