Skip to content

Commit 6c45c5b

Browse files
committed
use test themes during Pester test
1 parent 3d3f81c commit 6c45c5b

2 files changed

Lines changed: 14 additions & 69 deletions

File tree

tests/unit/Add-TerminalIconsColorTheme.tests.ps1

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,18 @@
11
InModuleScope 'Terminal-Icons' {
2-
32
Describe 'Add-TerminalIconsColorTheme' {
4-
53
Context 'Themes' {
6-
7-
Mock Export-CliXml {}
8-
9-
BeforeAll {
10-
$tmpDir = [IO.Path]::GetTempPath()
11-
$themePath = [IO.Path]::Combine($tmpDir, 'MyAwesomeTheme.psd1')
12-
$script:goodTheme = New-Item -Path $themePath -Force
13-
14-
$themeContent = @'
15-
@{
16-
Name = 'MyAwesomeTheme'
17-
Types = @{
18-
Directories = @{
19-
WellKnown = @{
20-
tests = '98FB98'
21-
}
22-
}
23-
Files = @{
24-
WellKnown = @{
25-
'.ps1' = '98FB98'
26-
}
27-
}
28-
}
29-
}
30-
'@
31-
$themeContent | Out-File $goodTheme -Encoding utf8
32-
$goodThemeName = $goodTheme.BaseName
33-
}
34-
354
AfterAll {
36-
$goodTheme | Remove-Item
5+
$themeStorage = Get-ThemeStoragePath
6+
Set-TerminalIconsTheme -ColorTheme devblackops -IconTheme devblackops
7+
Remove-Item (Join-Path $themeStorage 'MyAwesomeTheme_color.xml') -Force -ErrorAction SilentlyContinue
378
}
389

10+
Mock Export-CliXml {}
11+
3912
it 'Good theme should be added' {
40-
Add-TerminalIconsColorTheme -Path $goodTheme.FullName -Force
41-
$script:userThemeData.Themes.Color[$goodThemeName] | Should -BeOfType System.Collections.Hashtable
42-
$script:userThemeData.Themes.Color[$goodThemeName].Name | Should -Be 'MyAwesomeTheme'
13+
Add-TerminalIconsColorTheme -Path $PSScriptRoot/../MyAwesomeColorTheme.psd1 # $goodTheme.FullName -Force
14+
$script:userThemeData.Themes.Color['MyAwesomeTheme'] | Should -BeOfType System.Collections.Hashtable
15+
$script:userThemeData.Themes.Color['MyAwesomeTheme'].Name | Should -Be 'MyAwesomeTheme'
4316
}
4417

4518
it 'Bad theme path should throw' {

tests/unit/Add-TerminalIconsIconTheme.tests.ps1

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,18 @@
11
InModuleScope 'Terminal-Icons' {
22
Describe 'Add-TerminalIconsIconTheme' {
3-
43
Context 'Themes' {
5-
6-
BeforeAll {
7-
$tmpDir = [IO.Path]::GetTempPath()
8-
$themePath = [IO.Path]::Combine($tmpDir, 'MyAwesomeTheme.psd1')
9-
$script:goodTheme = New-Item -Path $themePath -Force
10-
11-
$themeContent = @'
12-
@{
13-
Name = 'MyAwesomeTheme'
14-
Types = @{
15-
Directories = @{
16-
WellKnown = @{
17-
tests = 'nf-fa-gear'
18-
}
19-
}
20-
Files = @{
21-
WellKnown = @{
22-
'.ps1' = 'nf-fa-gear'
23-
}
24-
}
25-
}
26-
}
27-
'@
28-
$themeContent | Out-File $goodTheme -Encoding utf8
29-
$goodThemeName = $goodTheme.BaseName
30-
}
31-
324
AfterAll {
33-
$goodTheme | Remove-Item
5+
$themeStorage = Get-ThemeStoragePath
6+
Set-TerminalIconsTheme -ColorTheme devblackops -IconTheme devblackops
7+
Remove-Item (Join-Path $themeStorage 'MyAwesomeTheme_icon.xml') -Force -ErrorAction SilentlyContinue
348
}
359

3610
Mock Export-CliXml {}
3711

38-
39-
4012
it 'Good theme should be added' {
41-
Add-TerminalIconsIconTheme -Path $goodTheme.FullName -Force
42-
$script:userThemeData.Themes.Icon[$goodThemeName] | Should -BeOfType System.Collections.Hashtable
43-
$script:userThemeData.Themes.Icon[$goodThemeName].Name | Should -Be 'MyAwesomeTheme'
13+
Add-TerminalIconsIconTheme -Path $PSScriptRoot/../MyAwesomeIconTheme.psd1 -Force
14+
$script:userThemeData.Themes.Icon['MyAwesomeTheme'] | Should -BeOfType System.Collections.Hashtable
15+
$script:userThemeData.Themes.Icon['MyAwesomeTheme'].Name | Should -Be 'MyAwesomeTheme'
4416
}
4517

4618
it 'Bad theme path should throw' {

0 commit comments

Comments
 (0)