/**
* Unit tests for lib/routes/archive.js
*
* Tests the parseArchiveFormat function used by the archive HTTP endpoint.
*/
import test from 'brittle'
import { parseArchiveFormat } from '../../lib/routes/archive.js'
// ========================================
// parseArchiveFormat
// ========================================
test('parseArchiveFormat - recognizes release.tar.gz', (t) => {
t.is(parseArchiveFormat('release.tar.gz'), 'tar.gz')
})
test('parseArchiveFormat - recognizes release.zip', (t) => {
t.is(parseArchiveFormat('release.zip'), 'zip')
})
test('parseArchiveFormat - rejects release.rar', (t) => {
t.is(parseArchiveFormat('release.rar'), null)
})
test('parseArchiveFormat - rejects bare release (no extension)', (t) => {
t.is(parseArchiveFormat('release'), null)
})
test('parseArchiveFormat - rejects empty string', (t) => {
t.is(parseArchiveFormat(''), null)
})
test('parseArchiveFormat - rejects null', (t) => {
t.is(parseArchiveFormat(null), null)
})
test('parseArchiveFormat - rejects undefined', (t) => {
t.is(parseArchiveFormat(undefined), null)
})