Files
shields/services/gitlab/gitlab-license.tester.js
dependabot[bot] b9d96755ec chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#9357)
* 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>
2023-07-10 09:27:51 +00:00

70 lines
1.8 KiB
JavaScript

import { licenseToColor } from '../licenses.js'
import { createServiceTester } from '../tester.js'
import { noToken } from '../test-helpers.js'
import _noGitLabToken from './gitlab-license.service.js'
export const t = await createServiceTester()
const noGitLabToken = noToken(_noGitLabToken)
const publicDomainLicenseColor = licenseToColor('MIT License')
const unknownLicenseColor = licenseToColor()
t.create('License')
.get('/guoxudong.io/shields-test/licenced-test.json')
.expectBadge({
label: 'license',
message: 'MIT License',
color: `${publicDomainLicenseColor}`,
})
t.create('License for repo without a license')
.get('/guoxudong.io/shields-test/no-license-test.json')
.expectBadge({
label: 'license',
message: 'not specified',
color: 'lightgrey',
})
t.create('Other license').get('/gitlab-org/gitlab-foss.json').expectBadge({
label: 'license',
message: 'Other',
color: unknownLicenseColor,
})
t.create('License for unknown repo')
.get('/user1/gitlab-does-not-have-this-repo.json')
.expectBadge({
label: 'license',
message: 'project not found',
color: 'red',
})
t.create('Mocking License')
.get('/group/project.json')
.intercept(nock =>
nock('https://gitlab.com')
.get('/api/v4/projects/group%2Fproject?license=1')
.reply(200, {
license: {
key: 'apache-2.0',
name: 'Apache License 2.0',
nickname: '',
html_url: 'http://choosealicense.com/licenses/apache-2.0/',
source_url: '',
},
}),
)
.expectBadge({
label: 'license',
message: 'Apache License 2.0',
color: unknownLicenseColor,
})
t.create('License (private repo)')
.skipWhen(noGitLabToken)
.get('/shields-ops-group/test.json')
.expectBadge({
label: 'license',
message: 'MIT License',
color: `${publicDomainLicenseColor}`,
})