diff --git a/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 b/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 index e8268ab..ebd5d30 100644 --- a/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 +++ b/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 @@ -41,7 +41,9 @@ function Get-ChannelForgeChannelCategory { } $nameHits = @(Find-ChannelForgeCategoryWord -Text $Name -Registry $Registry -Property NameTokens) - $groupHits = @(Find-ChannelForgeCategoryWord -Text $ProviderGroup -Registry $Registry -Property Aliases) + # A provider group may be a league tag such as "NHL", so group text is checked against the same league tokens as the name. + $groupHits = @(Find-ChannelForgeCategoryWord -Text $ProviderGroup -Registry $Registry -Property Aliases) + + @(Find-ChannelForgeCategoryWord -Text $ProviderGroup -Registry $Registry -Property NameTokens) $groupSpecific = @($groupHits | Where-Object { $_.Key -ne 'other-sports' }) $isGeneric = $groupHits.Count -gt $groupSpecific.Count $keys = @(@($nameHits) + $groupSpecific | ForEach-Object { $_.Key } | Select-Object -Unique) diff --git a/tests/unit/CategoryReport.Tests.ps1 b/tests/unit/CategoryReport.Tests.ps1 index e43cf02..2cbbf02 100644 --- a/tests/unit/CategoryReport.Tests.ps1 +++ b/tests/unit/CategoryReport.Tests.ps1 @@ -118,3 +118,26 @@ Describe 'Category overrides: corrections the owner keeps' { [IO.File]::ReadAllBytes($script:OverridePath) | Should -Be $before } } + +Describe 'Channel category: league tag in the provider group' { + BeforeAll { + function Get-Decision { param([string]$Name, [string]$Group) & (Get-Module ChannelForge) { param($n, $g) Get-ChannelForgeChannelCategory -Name $n -ProviderGroup $g -Key 'k' } $Name $Group } + } + + It 'puts a game-feed channel in an NHL group under hockey, even with an empty name' { + (Get-Decision 'Vancouver Canucks @ Utah Mammoth [Mammoth Feed]' 'NHL').Category | Should -Be 'hockey' + (Get-Decision '' 'NHL').Category | Should -Be 'hockey' + } + + It 'gives no category when the name and the NHL group disagree' { + $result = Get-Decision 'NBA TV' 'NHL' + $result.Category | Should -BeNullOrEmpty + $result.Decision | Should -Be 'conflict' + } + + It 'keeps the MLB, NBA and NFL categories' { + (Get-Decision 'MLB 01: No event today' 'MLB').Category | Should -Be 'baseball' + (Get-Decision 'NBA (ATL) Atlanta Hawks (A)' 'NBA').Category | Should -Be 'basketball' + (Get-Decision 'NFL RedZone' 'NFL').Category | Should -Be 'football' + } +}