Skip to content

Commit

Permalink
test(scripts): fix failing changelog unit test (#1626)
Browse files Browse the repository at this point in the history
The markdown changelog is generated with a date, updated test harness to
use Sinon's fake timers feature to lock the clock to a specific date so
our assertion doesn't have to change every day.
  • Loading branch information
jmartin4563 authored May 8, 2023
1 parent 880a88b commit 08f48b3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bin/test/conventional-changelog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const exampleCommit = {
}
}

const exampleMarkdown = `### v1.0.0 (2023-05-05)
const exampleMarkdown = `### v1.0.0 (2020-04-03)
#### ⚠ BREAKING CHANGES
Expand All @@ -68,12 +68,14 @@ const exampleMarkdown = `### v1.0.0 (2023-05-05)
tap.test('Conventional Changelog Class', (testHarness) => {
testHarness.autoend()

let clock
let MockGithubSdk
let mockGetPrByCommit
let mockGitLog
let ConventionalChangelog

testHarness.beforeEach(() => {
clock = sinon.useFakeTimers(new Date('2020-04-03'))
mockGetPrByCommit = sinon.stub()
MockGithubSdk = sinon.stub().returns({
getPullRequestByCommit: mockGetPrByCommit
Expand All @@ -87,6 +89,10 @@ tap.test('Conventional Changelog Class', (testHarness) => {
})
})

testHarness.afterEach(() => {
clock.restore()
})

testHarness.test('rankedGroupSort - should order a list of groupings based on rank', (t) => {
const changelog = new ConventionalChangelog({ newVersion: '1.0.0', previousVersion: '0.9.0' })

Expand Down

0 comments on commit 08f48b3

Please sign in to comment.