Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/CategoryReport.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Loading