Skip to content

Commit

Permalink
make update-version more testable
Browse files Browse the repository at this point in the history
  • Loading branch information
jumoog committed Sep 28, 2024
1 parent 1174033 commit aee7689
Show file tree
Hide file tree
Showing 7 changed files with 828 additions and 771 deletions.
50 changes: 49 additions & 1 deletion __tests__/update-version.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { incrementVersion } from '../src/update-version'
import { incrementVersion, updateVersionsInData } from '../src/update-version'

describe('update-version', () => {
describe('incrementVersion', () => {
Expand All @@ -8,4 +8,52 @@ describe('update-version', () => {
expect(incrementVersion('1.0.9')).toBe('1.0.10')
})
})

describe('updateVersionsInData', () => {
it('should update AssemblyVersion and FileVersion in the data', () => {
const inputData = `
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
</PropertyGroup>
</Project>
`

const expectedOutput = `
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>1.0.1</AssemblyVersion>
<FileVersion>1.0.1</FileVersion>
</PropertyGroup>
</Project>
`

const { updatedData, newAssemblyVersion, newFileVersion } =
updateVersionsInData(inputData)

expect(updatedData.trim()).toBe(expectedOutput.trim())
expect(newAssemblyVersion).toBe('1.0.1')
expect(newFileVersion).toBe('1.0.1')
})

it('should handle different versions for AssemblyVersion and FileVersion', () => {
const inputData = `
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>1.2.3</AssemblyVersion>
<FileVersion>2.3.4</FileVersion>
</PropertyGroup>
</Project>
`

const { updatedData, newAssemblyVersion, newFileVersion } =
updateVersionsInData(inputData)

expect(updatedData).toContain('<AssemblyVersion>1.2.4</AssemblyVersion>')
expect(updatedData).toContain('<FileVersion>2.3.5</FileVersion>')
expect(newAssemblyVersion).toBe('1.2.4')
expect(newFileVersion).toBe('2.3.5')
})
})
})
Loading

0 comments on commit aee7689

Please sign in to comment.