package api

import (
	"testing"

	"github.com/ponzischeme89/memby/server/internal/store"
)

func TestSessionPlaybackCapabilitiesParsesAudioEvidence(t *testing.T) {
	capabilities := sessionPlaybackCapabilities(store.Session{ClientCapabilities: []string{
		"audio_passthrough_v1",
		"audio_eac3_passthrough",
		"audio_truehd_decode",
		"audio_max_channels_8",
		"audio_unknown_passthrough",
	}})
	if !capabilities.AudioProfileV1 || !capabilities.AudioPassthrough["eac3"] {
		t.Fatalf("passthrough evidence = %#v", capabilities)
	}
	if !capabilities.AudioDecode["truehd"] || capabilities.AudioMaxChannels != 8 {
		t.Fatalf("decode evidence = %#v", capabilities)
	}
	if capabilities.AudioPassthrough["unknown"] {
		t.Fatalf("unknown audio codec was accepted: %#v", capabilities.AudioPassthrough)
	}
}
