Add input tests
This commit is contained in:
@@ -5,19 +5,39 @@ import { Context } from "@actions/github/lib/context";
|
||||
|
||||
|
||||
jest.mock('@actions/core', () => {
|
||||
return {getInput: mockGetInput};
|
||||
return { getInput: mockGetInput };
|
||||
});
|
||||
|
||||
describe('Inputs', () => {
|
||||
let context: Context
|
||||
let inputs: Inputs
|
||||
let context: Context;
|
||||
let inputs: Inputs;
|
||||
beforeEach(() => {
|
||||
context = new Context()
|
||||
inputs = new Inputs(context)
|
||||
mockGetInput.mockReturnValue("")
|
||||
})
|
||||
it('returns token', () => {
|
||||
|
||||
it('token method returns input token', () => {
|
||||
mockGetInput.mockReturnValue("42")
|
||||
expect(inputs.token).toBe("42")
|
||||
})
|
||||
|
||||
describe('tag', () => {
|
||||
it('tag property returns input tag', () => {
|
||||
mockGetInput.mockReturnValue("tag")
|
||||
expect(inputs.tag).toBe("tag")
|
||||
})
|
||||
it('tag property returns context sha when input is empty', () => {
|
||||
mockGetInput.mockReturnValue("")
|
||||
context.ref = "refs/tags/sha-tag"
|
||||
expect(inputs.tag).toBe("sha-tag")
|
||||
})
|
||||
it('tag property returns context sha when input is null', () => {
|
||||
mockGetInput.mockReturnValue(null)
|
||||
context.ref = "refs/tags/sha-tag"
|
||||
expect(inputs.tag).toBe("sha-tag")
|
||||
})
|
||||
it('tag property throws if no tag', () => {
|
||||
expect(() => inputs.tag).toThrow()
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user