* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * reformat all the things (prettier 3) * update tests to await calls to prettier.format() --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: chris48s <git@chris-shaw.dev>
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
import { expect } from 'chai'
|
|
import sinon from 'sinon'
|
|
import { InvalidResponse } from '../index.js'
|
|
import GitHubCommitActivity from './github-commit-activity.service.js'
|
|
|
|
describe('GitHubCommitActivity', function () {
|
|
describe('transform', function () {
|
|
it('throws InvalidResponse on invalid branch and null object', function () {
|
|
expect(() =>
|
|
GitHubCommitActivity.transform({
|
|
data: { repository: { object: null } },
|
|
}),
|
|
)
|
|
.to.throw(InvalidResponse)
|
|
.with.property('prettyMessage', 'invalid branch')
|
|
})
|
|
})
|
|
describe('getIntervalQueryStartDate', function () {
|
|
/** @type {sinon.SinonFakeTimers} */
|
|
let clock
|
|
beforeEach(function () {
|
|
clock = sinon.useFakeTimers()
|
|
})
|
|
afterEach(function () {
|
|
clock.restore()
|
|
})
|
|
|
|
it('provides correct value for yearly interval', function () {
|
|
clock.tick(new Date('2021-08-28T02:21:34.000Z').getTime())
|
|
expect(
|
|
GitHubCommitActivity.getIntervalQueryStartDate({
|
|
interval: 'y',
|
|
}),
|
|
).to.equal('2020-08-28T02:21:34.000Z')
|
|
})
|
|
|
|
it('provides correct value for simple monthly interval', function () {
|
|
clock.tick(new Date('2021-03-31T02:21:34.000Z').getTime())
|
|
expect(
|
|
GitHubCommitActivity.getIntervalQueryStartDate({
|
|
interval: 'm',
|
|
}),
|
|
).to.equal('2021-03-01T02:21:34.000Z')
|
|
})
|
|
|
|
it('provides correct value for fun monthly interval', function () {
|
|
clock.tick(new Date('2021-03-07T02:21:34.000Z').getTime())
|
|
expect(
|
|
GitHubCommitActivity.getIntervalQueryStartDate({
|
|
interval: '4w',
|
|
}),
|
|
).to.equal('2021-02-05T02:21:34.000Z')
|
|
})
|
|
|
|
it('provides correct value for weekly interval', function () {
|
|
clock.tick(new Date('2021-12-31T23:59:34.000Z').getTime())
|
|
expect(
|
|
GitHubCommitActivity.getIntervalQueryStartDate({
|
|
interval: 'w',
|
|
}),
|
|
).to.equal('2021-12-24T23:59:34.000Z')
|
|
})
|
|
})
|
|
})
|