-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathAdd-PSRunEntryGroup.Tests.ps1
More file actions
63 lines (55 loc) · 2.48 KB
/
Copy pathAdd-PSRunEntryGroup.Tests.ps1
File metadata and controls
63 lines (55 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Describe 'Add-PSRunEntryGroup' {
BeforeEach {
Import-Module $PSScriptRoot/../../module/PowerShellRun -Force
}
It 'should add a normal entry group' {
Enable-PSRunEntry -Category EntryGroup
Add-PSRunEntryGroup -Icon '😆' -Name 'Custom Name' -Description 'Custom Desc' -Preview 'Custom Preview'
InModuleScope 'PowerShellRun' {
$registry = $script:globalStore.GetRegistry('EntryGroupRegistry')
$registry.entries.Count | Should -Be 1
}
}
It 'should add a category entry group' {
Enable-PSRunEntry -Category EntryGroup
Add-PSRunEntryGroup -Icon '😆' -Name 'Custom Name' -Description 'Custom Desc' -Preview 'Custom Preview' -Category Function
InModuleScope 'PowerShellRun' {
$registry = $script:globalStore.GetRegistry('EntryGroupRegistry')
$registry.entries.Count | Should -Be 1
}
}
It 'should add the entry under an entry group' {
Enable-PSRunEntry -Category EntryGroup
$parentGroup = Add-PSRunEntryGroup -Name 'Parent Group' -PassThru
Add-PSRunEntryGroup -Name 'Custom Name' -EntryGroup $parentGroup
$parentGroup.DirectChildEntries.Count | Should -Be 1
InModuleScope 'PowerShellRun' {
$registry = $script:globalStore.GetRegistry('EntryGroupRegistry')
$registry.entries.Count | Should -Be 1
}
}
It 'should not add an entry if category is disabled' {
Enable-PSRunEntry -Category Function
{ Add-PSRunEntryGroup -Icon '😆' -Name 'Custom Name' -Description 'Custom Desc' -Preview 'Custom Preview' -WarningAction Stop } | Should -Throw
InModuleScope 'PowerShellRun' {
$registry = $script:globalStore.GetRegistry('EntryGroupRegistry')
$registry.entries.Count | Should -Be 0
}
}
It 'should return the entry group with PassThru' {
Enable-PSRunEntry -Category EntryGroup
$group = Add-PSRunEntryGroup -Name 'Custom Name' -PassThru
$group | Should -Not -BeNullOrEmpty
}
It 'should accept a pipeline input' {
Enable-PSRunEntry -Category EntryGroup
'Custom Name' | Add-PSRunEntryGroup
InModuleScope 'PowerShellRun' {
$registry = $script:globalStore.GetRegistry('EntryGroupRegistry')
$registry.entries.Count | Should -Be 1
}
}
AfterEach {
Remove-Module PowerShellRun -Force
}
}