1
0
mirror of https://github.com/badges/shields.git synced 2025-04-18 19:44:04 +03:00
shields/services/github/github-last-commit.tester.js
ReubenFrankel 4f141dfa84
[GithubLastCommit] [GitlabLastCommit] [GiteaLastCommit] Support file path for last commit (#10041)
* Support file path for GitHub last commit

* Support file path for GitLab last commit

* Support file path for Gitea last commit

* Define common `relativeUri` validator

* Sort imports

* Add more tests for path variations

* Fix test name

Co-authored-by: chris48s <chris48s@users.noreply.github.com>

* Update Gitea 404 message

* Handle case when no commits are returned for GitHub and GitLab

---------

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2024-03-25 12:10:04 +00:00

48 lines
1.8 KiB
JavaScript

import { isFormattedDate } from '../test-validators.js'
import { createServiceTester } from '../tester.js'
export const t = await createServiceTester()
t.create('last commit (recent)')
.get('/eslint/eslint.json')
.expectBadge({ label: 'last commit', message: isFormattedDate })
t.create('last commit (ancient)')
.get('/badges/badgr.co.json')
.expectBadge({ label: 'last commit', message: 'january 2014' })
t.create('last commit (on branch)')
.get('/badges/badgr.co/shielded.json')
.expectBadge({ label: 'last commit', message: 'july 2013' })
t.create('last commit (by top-level file path)')
.get('/badges/badgr.co.json?path=README.md')
.expectBadge({ label: 'last commit', message: 'september 2013' })
t.create('last commit (by top-level dir path)')
.get('/badges/badgr.co.json?path=badgr')
.expectBadge({ label: 'last commit', message: 'june 2013' })
t.create('last commit (by top-level dir path with trailing slash)')
.get('/badges/badgr.co.json?path=badgr/')
.expectBadge({ label: 'last commit', message: 'june 2013' })
t.create('last commit (by nested file path)')
.get('/badges/badgr.co.json?path=badgr/colors.py')
.expectBadge({ label: 'last commit', message: 'june 2013' })
t.create('last commit (on branch) (by top-level file path)')
.get('/badges/badgr.co/shielded.json?path=README.md')
.expectBadge({ label: 'last commit', message: 'june 2013' })
t.create('last commit (by committer)')
.get('/badges/badgr.co/shielded.json?display_timestamp=committer')
.expectBadge({ label: 'last commit', message: 'july 2013' })
t.create('last commit (repo not found)')
.get('/badges/helmets.json')
.expectBadge({ label: 'last commit', message: 'repo not found' })
t.create('last commit (no commits found)')
.get('/badges/badgr.co/shielded.json?path=not/a/dir')
.expectBadge({ label: 'last commit', message: 'no commits found' })