-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from embroider-build/updateChangelog-test
add a basic test for updateChangelog
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
|
||
import { updateChangelog } from './prepare.js'; | ||
|
||
const mocks = vi.hoisted(() => { | ||
return { | ||
readFileSync: vi.fn().mockImplementation(() => ''), | ||
writeFileSync: vi.fn().mockImplementation(() => ''), | ||
}; | ||
}); | ||
|
||
vi.mock('node:fs', () => { | ||
return mocks; | ||
}); | ||
|
||
describe('prepare', function () { | ||
describe('updateChangelog', function () { | ||
it('updates changelog correctly', function () { | ||
mocks.readFileSync.mockReturnValue(`# A Totally ficticious Changelog | ||
## Some Old version | ||
- added some features | ||
- spent a lot of time trying to figure out releases (if only there was a tool to help with that) | ||
`); | ||
updateChangelog( | ||
`## v1.0.0 | ||
- added release-plan (how did I live without it!?) | ||
- releasing initial working version`, | ||
new Map([['thing', { newVersion: 'v1.0.0', impact: 'major' }]]) as any, | ||
); | ||
const [, newChangelog] = mocks.writeFileSync.mock.lastCall; | ||
expect(newChangelog).to.eq(`# A Totally ficticious Changelog | ||
## v1.0.0 | ||
thing v1.0.0 (major) | ||
- added release-plan (how did I live without it!?) | ||
- releasing initial working version | ||
## Some Old version | ||
- added some features | ||
- spent a lot of time trying to figure out releases (if only there was a tool to help with that) | ||
`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters