Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/__test__/input-helper.test.ts
diff options
context:
space:
mode:
authoreric sciple <ericsciple@users.noreply.github.com>2020-03-02 11:33:30 -0500
committerGitHub <noreply@github.com>2020-03-02 11:33:30 -0500
commit684bbf983233d1341d533f6fe471109f385c631a (patch)
treeb1b1ad193814c44cf1e7b450c00c005ed96c0a6d /__test__/input-helper.test.ts
parentdee20e9b25075b7e4d2fc1569a2e99e21905e978 (diff)
more unit tests and corresponding refactoring (#174)
Diffstat (limited to '__test__/input-helper.test.ts')
-rw-r--r--__test__/input-helper.test.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/__test__/input-helper.test.ts b/__test__/input-helper.test.ts
index be4b166..53c7000 100644
--- a/__test__/input-helper.test.ts
+++ b/__test__/input-helper.test.ts
@@ -4,7 +4,7 @@ import * as fsHelper from '../lib/fs-helper'
import * as github from '@actions/github'
import * as inputHelper from '../lib/input-helper'
import * as path from 'path'
-import {ISourceSettings} from '../lib/git-source-provider'
+import {IGitSourceSettings} from '../lib/git-source-settings'
const originalGitHubWorkspace = process.env['GITHUB_WORKSPACE']
const gitHubWorkspace = path.resolve('/checkout-tests/workspace')
@@ -17,12 +17,18 @@ let originalContext = {...github.context}
describe('input-helper tests', () => {
beforeAll(() => {
- // Mock @actions/core getInput()
+ // Mock getInput
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
return inputs[name]
})
- // Mock @actions/github context
+ // Mock error/warning/info/debug
+ jest.spyOn(core, 'error').mockImplementation(jest.fn())
+ jest.spyOn(core, 'warning').mockImplementation(jest.fn())
+ jest.spyOn(core, 'info').mockImplementation(jest.fn())
+ jest.spyOn(core, 'debug').mockImplementation(jest.fn())
+
+ // Mock github context
jest.spyOn(github.context, 'repo', 'get').mockImplementation(() => {
return {
owner: 'some-owner',
@@ -62,7 +68,7 @@ describe('input-helper tests', () => {
})
it('sets defaults', () => {
- const settings: ISourceSettings = inputHelper.getInputs()
+ const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings).toBeTruthy()
expect(settings.authToken).toBeFalsy()
expect(settings.clean).toBe(true)
@@ -80,7 +86,7 @@ describe('input-helper tests', () => {
let originalRef = github.context.ref
try {
github.context.ref = 'some-unqualified-ref'
- const settings: ISourceSettings = inputHelper.getInputs()
+ const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings).toBeTruthy()
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
expect(settings.ref).toBe('refs/heads/some-unqualified-ref')
@@ -98,7 +104,7 @@ describe('input-helper tests', () => {
it('roots path', () => {
inputs.path = 'some-directory/some-subdirectory'
- const settings: ISourceSettings = inputHelper.getInputs()
+ const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings.repositoryPath).toBe(
path.join(gitHubWorkspace, 'some-directory', 'some-subdirectory')
)
@@ -106,21 +112,21 @@ describe('input-helper tests', () => {
it('sets correct default ref/sha for other repo', () => {
inputs.repository = 'some-owner/some-other-repo'
- const settings: ISourceSettings = inputHelper.getInputs()
+ const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings.ref).toBe('refs/heads/master')
expect(settings.commit).toBeFalsy()
})
it('sets ref to empty when explicit sha', () => {
inputs.ref = '1111111111222222222233333333334444444444'
- const settings: ISourceSettings = inputHelper.getInputs()
+ const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings.ref).toBeFalsy()
expect(settings.commit).toBe('1111111111222222222233333333334444444444')
})
it('sets sha to empty when explicit ref', () => {
inputs.ref = 'refs/heads/some-other-ref'
- const settings: ISourceSettings = inputHelper.getInputs()
+ const settings: IGitSourceSettings = inputHelper.getInputs()
expect(settings.ref).toBe('refs/heads/some-other-ref')
expect(settings.commit).toBeFalsy()
})