A release the window closed on with one file named by its stem or post, the name with a number and no archive, volume, sidecar or random name, waits in the album of its poster and template (the name's digit runs as #, the extension apart) posted within the window of the album's first file; the album closes a window after that span and is written as one release (source album, no file total) named by the members' shared numbers, a lone member as the release it was. The batch store writes an album's member names as release_texts kind 6 (member). A counter total of 100 or more under which one poster started 20 or more releases is a batch counter: those releases get no file total. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { test } from '@japa/runner'
|
|
import {
|
|
TEXT_KINDS,
|
|
TEXTS_PER_KIND,
|
|
TEXT_MAX,
|
|
textKindCode,
|
|
textKindName,
|
|
textsToStore,
|
|
} from '#lib/release/text_kind'
|
|
|
|
test.group('release text kinds', () => {
|
|
test('names and codes map both ways; the codes are fixed', ({ assert }) => {
|
|
assert.deepEqual(TEXT_KINDS, { name: 1, file: 2, nfo: 3, par2: 4, media: 5, member: 6 })
|
|
for (const [name, code] of Object.entries(TEXT_KINDS)) {
|
|
assert.equal(textKindCode(name), code)
|
|
assert.equal(textKindName(code), name)
|
|
assert.equal(textKindName(String(code)), name)
|
|
}
|
|
})
|
|
|
|
test('an unknown name throws, an unknown code reads as unknown', ({ assert }) => {
|
|
assert.throws(() => textKindCode('title'), /Unknown release text kind/)
|
|
assert.equal(textKindName(99), 'unknown')
|
|
assert.equal(textKindName(null), 'unknown')
|
|
})
|
|
|
|
test('textsToStore trims, cuts, drops empties and repeats, keeps the first TEXTS_PER_KIND', ({
|
|
assert,
|
|
}) => {
|
|
const long = 'x'.repeat(TEXT_MAX + 10)
|
|
assert.deepEqual(textsToStore([' a.mkv ', '', null, 'a.mkv', 'b.mkv', long]), [
|
|
'a.mkv',
|
|
'b.mkv',
|
|
'x'.repeat(TEXT_MAX),
|
|
])
|
|
const many = Array.from({ length: TEXTS_PER_KIND + 5 }, (_, i) => `file${i}.rar`)
|
|
const kept = textsToStore(many)
|
|
assert.lengthOf(kept, TEXTS_PER_KIND)
|
|
assert.equal(kept[0], 'file0.rar')
|
|
assert.equal(kept[TEXTS_PER_KIND - 1], `file${TEXTS_PER_KIND - 1}.rar`)
|
|
})
|
|
})
|