Files
shields/services/github/github-go-mod.spec.js
Marat Reymers caea7597f9 [GitHubGoMod] Ignore comment after version (fixes #10079) (#10080)
* [GithubGoMod] Ignore comment after version (fixes #10079)

* add unit tests for GithubGoModGoVersion.transform

---------

Co-authored-by: chris48s <git@chris-shaw.dev>
2024-04-07 08:02:49 +00:00

27 lines
1009 B
JavaScript

import { expect } from 'chai'
import { test, given } from 'sazerac'
import { InvalidResponse } from '../index.js'
import GithubGoModGoVersion from './github-go-mod.service.js'
describe('GithubGoModGoVersion', function () {
describe('valid cases', function () {
test(GithubGoModGoVersion.transform, () => {
given('go 1.18').expect({ go: '1.18' })
given('go 1.18 // inline comment').expect({ go: '1.18' })
given('go 1.18// inline comment').expect({ go: '1.18' })
given('go 1.18 /* block comment */').expect({ go: '1.18' })
given('go 1.18/* block comment */').expect({ go: '1.18' })
given('go 1').expect({ go: '1' })
given('go 1.2.3').expect({ go: '1.2.3' })
given('go string').expect({ go: 'string' })
})
})
describe('invalid cases', function () {
expect(() => GithubGoModGoVersion.transform('')).to.throw(InvalidResponse)
expect(() =>
GithubGoModGoVersion.transform("doesn't start with go"),
).to.throw(InvalidResponse)
})
})