Skip to content

Commit

Permalink
test: add extractVersion test
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Jan 12, 2024
1 parent f0adb5b commit 7956bd8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {describe, test, expect} from '@jest/globals'
import {extractVersion} from '../src/utils'

// shows how the runner will run a javascript action with env / stdout protocol
describe('extractVersion', () => {
test('should return the version if the branch convention is valid', () => {
expect(extractVersion('hotfix/1.2.3')).toBe('1.2.3')
expect(extractVersion('hotfix/v1.2.3')).toBe('1.2.3')
expect(extractVersion('hotfix/ktx/v1.2.3')).toBe('1.2.3')

expect(extractVersion('release/1.2.3')).toBe('1.2.3')
expect(extractVersion('release/v1.2.3')).toBe('1.2.3')
expect(extractVersion('release/ktx/v1.2.3')).toBe('1.2.3')
})

test('Should return an empty string if the branch convention is invalid', () => {
expect(extractVersion('v1.2.3')).toBe('')
expect(extractVersion('1.2.3')).toBe('')
expect(extractVersion('unknown/1.2.3')).toBe('')
expect(extractVersion('hotfixx/1.2.3')).toBe('')
expect(extractVersion('hotfixx/v1.2.3')).toBe('')
expect(extractVersion('releases/1.2.3')).toBe('')
expect(extractVersion('releases/v1.2.3')).toBe('')
})
})

0 comments on commit 7956bd8

Please sign in to comment.