Skip to content

Commit

Permalink
Added tests for variations of release type string casing
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-v committed Oct 10, 2023
1 parent 45c9385 commit 56d1607
Showing 1 changed file with 105 additions and 3 deletions.
108 changes: 105 additions & 3 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('action', () => {
expect(runMock).toHaveReturned()
})

it('valid version json; update major', async () => {
it('valid version json; update major 1', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
Expand All @@ -55,7 +55,41 @@ describe('action', () => {
expect(runMock).toHaveReturned()
})

it('valid version json; update minor', async () => {
it('valid version json; update major 2', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'release-type':
return 'Major'
case 'version-json':
return '{"major":31,"minor":1,"patch":0,"build":457,"revision":0,"versionSuffix":"alpha"}'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
})

it('valid version json; update major 3', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'release-type':
return 'major'
case 'version-json':
return '{"major":31,"minor":1,"patch":0,"build":457,"revision":0,"versionSuffix":"alpha"}'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
})

it('valid version json; update minor 1', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
Expand All @@ -72,7 +106,41 @@ describe('action', () => {
expect(runMock).toHaveReturned()
})

it('valid version json; update patch', async () => {
it('valid version json; update minor 2', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'release-type':
return 'Minor'
case 'version-json':
return '{"major":31,"minor":1,"patch":0,"build":457,"revision":0,"versionSuffix":"alpha"}'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
})

it('valid version json; update minor 3', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'release-type':
return 'minor'
case 'version-json':
return '{"major":31,"minor":1,"patch":0,"build":457,"revision":0,"versionSuffix":"alpha"}'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
})

it('valid version json; update patch 1', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
Expand All @@ -89,6 +157,40 @@ describe('action', () => {
expect(runMock).toHaveReturned()
})

it('valid version json; update patch 2', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'release-type':
return 'Patch'
case 'version-json':
return '{"major":31,"minor":1,"patch":0,"build":457,"revision":0,"versionSuffix":"alpha"}'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
})

it('valid version json; update patch 3', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'release-type':
return 'patch'
case 'version-json':
return '{"major":31,"minor":1,"patch":0,"build":457,"revision":0,"versionSuffix":"alpha"}'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
})

it('invalid update type', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
Expand Down

0 comments on commit 56d1607

Please sign in to comment.