Skip to content

Commit 795d995

Browse files
committed
test: add input repository tests
1 parent 090c4f6 commit 795d995

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

__tests__/main.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,42 @@ describe('action', () => {
205205
})
206206
})
207207

208+
describe('input repository is given', () => {
209+
describe('valid format', () => {
210+
beforeEach(() => {
211+
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
212+
if (name == 'repository') return 'the-user/the-repo'
213+
return ''
214+
})
215+
})
216+
217+
it('succeed', async () => {
218+
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
219+
await main.run()
220+
expect(setFailedMock).toHaveBeenCalledWith(
221+
'Neither files nor tag input has been configured'
222+
)
223+
})
224+
})
225+
226+
describe('invalid format', () => {
227+
beforeEach(() => {
228+
jest.spyOn(core, 'getInput').mockImplementation((name, _option) => {
229+
if (name == 'repository') return 'the-user-the-repo'
230+
return ''
231+
})
232+
})
233+
234+
it('fails', async () => {
235+
const setFailedMock = jest.spyOn(core, 'setFailed').mockReturnValue()
236+
await main.run()
237+
expect(setFailedMock).toHaveBeenCalledWith(
238+
'Input <repository> "the-user-the-repo" is invalid'
239+
)
240+
})
241+
})
242+
})
243+
208244
describe('input branch is given', () => {
209245
beforeEach(() => {
210246
jest.spyOn(core, 'getMultilineInput').mockReturnValue(['/test.txt'])

0 commit comments

Comments
 (0)