import { test } from '@japa/runner'
import { withPassword } from '#services/nzb_service'
import { parseNzb } from '#lib/nzb/index'
const NZB = (head: string) =>
`${head}a.b.xa@x`
test.group('nzb / a read NZB with the password', () => {
test('added into its head, or a head made; one it has already is kept', ({ assert }) => {
assert.equal(parseNzb(withPassword(NZB('
x'), 'p<&>w'))!.meta.password, 'p<&>w')
assert.equal(parseNzb(withPassword(NZB(''), 'pw'))!.meta.password, 'pw')
assert.equal(parseNzb(withPassword(NZB('own'), 'pw'))!.meta.password, 'own')
assert.equal(withPassword(NZB(''), undefined), NZB(''))
})
})