mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 02:46:16 -08:00
test(portals): pin what the declared audio shape can and cannot say
The array shape the mock server and many panels send carries a codec and no language, so the dub warning is silent for every source arriving that way. Asserted rather than assumed, alongside the ffprobe shapes that do carry one — otherwise a later reader sees an unused field and wires the codec back into the warning. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b3b6272772
commit
960a33940f
1 file changed
+27
-2
+27
-2
@@ -5,8 +5,11 @@ import { readStreamInfo } from './vod-source-resolver.service';
|
||||
*
|
||||
* The declared shape is a string array and that is what the mock server and
|
||||
* many panels send; others send the ffprobe object. Reading only one of them
|
||||
* loses the provider's codec on every response of the other kind — and with
|
||||
* it the "dub may differ" warning, which compares stated audio tracks.
|
||||
* loses the provider's codec on every response of the other kind.
|
||||
*
|
||||
* What the array shape carries is a CODEC and nothing else — no language — so
|
||||
* it can never feed the "dub may differ" warning. That is the honest outcome
|
||||
* rather than a gap: a codec cannot tell one dub from another.
|
||||
*/
|
||||
describe('readStreamInfo', () => {
|
||||
it('reads the declared array shape', () => {
|
||||
@@ -30,6 +33,28 @@ describe('readStreamInfo', () => {
|
||||
expect(readStreamInfo([' H.264 '])).toEqual({ codec_name: 'H.264' });
|
||||
});
|
||||
|
||||
it('finds no language in the declared array shape', () => {
|
||||
// The shape the repo's own mock sends. It states a codec, so the dub
|
||||
// warning stays silent on every source that arrives this way — which
|
||||
// is most of them, and is correct: AAC says nothing about which dub
|
||||
// this is.
|
||||
const audio = readStreamInfo(['AAC']);
|
||||
|
||||
expect(audio?.language).toBeUndefined();
|
||||
expect(audio?.tags?.language).toBeUndefined();
|
||||
});
|
||||
|
||||
it('reads the language out of ffprobe tags when a panel sends them', () => {
|
||||
expect(
|
||||
readStreamInfo({ codec_name: 'ac3', tags: { language: 'rus' } })
|
||||
?.tags?.language
|
||||
).toBe('rus');
|
||||
// Some panels hoist it out of `tags`.
|
||||
expect(
|
||||
readStreamInfo({ codec_name: 'ac3', language: 'eng' })?.language
|
||||
).toBe('eng');
|
||||
});
|
||||
|
||||
it('says nothing when the provider said nothing', () => {
|
||||
// Empty beats wrong: an absent codec must not become a stated one.
|
||||
expect(readStreamInfo([])).toBeUndefined();
|
||||
|
||||
Reference in new issue
Block a user