setup-hugo/__tests__/asset-lookup.test.ts

40 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2024-05-02 16:38:23 +00:00
import { OctokitReleaseLookup } from '../src/asset-lookup'
import { Platform } from '../src/os'
import { HugoReleaseTransformer } from '../src/hugo'
import { DartSass, Hugo } from '../src/constants'
import { DartSassReleaseTransformer } from '../src/dart-sass'
beforeEach(() => {
jest.resetModules()
})
describe('Asset lookup', () => {
test('Hugo: should return valid version', async () => {
2024-05-03 14:17:32 +00:00
const releaseLookup = new OctokitReleaseLookup()
2024-05-02 16:38:23 +00:00
2024-05-03 14:17:32 +00:00
const release = await releaseLookup.getRelease(
2024-05-02 16:38:23 +00:00
Hugo.Org,
Hugo.Repo,
2024-05-02 17:36:40 +00:00
'latest',
2024-05-02 16:38:23 +00:00
HugoReleaseTransformer
)
expect(release.tag_name).toMatch(new RegExp('\\d+.\\d+.\\d+'))
const archiveUrl = release.assetUrl(new Platform(), false)
expect(archiveUrl).not.toBe(undefined)
})
test('Dart-Sass: should return valid version', async () => {
const octoVersionDetermination = new OctokitReleaseLookup()
const release = await octoVersionDetermination.getRelease(
DartSass.Org,
DartSass.Repo,
'',
DartSassReleaseTransformer
)
expect(release.tag_name).toMatch(new RegExp('\\d+.\\d+.\\d+'))
const archiveUrl = release.assetUrl(new Platform())
expect(archiveUrl).not.toBe(undefined)
})
})