Skip to content

Commit e5a80b7

Browse files
committed
add tests for Select-PSFObject from other non-object variables
1 parent 97014a0 commit e5a80b7

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

PSFramework/tests/functions/utility/Select-PSFObject.Tests.ps1

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Describe "Select-PSFObject Unit Tests" -Tag "UnitTests" {
1+
Describe "Select-PSFObject Unit Tests" -Tag "UnitTests" {
22
BeforeAll {
33
$object = [PSCustomObject]@{
44
Foo = 42
@@ -18,6 +18,8 @@
1818
Bar = 88
1919
Tara = 28
2020
}
21+
22+
$variable = 42
2123
}
2224

2325
Describe "Basic DSL functionalities" {
@@ -34,17 +36,26 @@
3436
($object2 | Select-PSFObject -Property 'Foo size KB:1:1').Foo | Should -Be "41 KB"
3537
}
3638
}
37-
38-
Describe "Selects from other variables" {
39-
It "picks values from other variables" {
39+
40+
Describe "Selects from other object variables" {
41+
It "picks values from other object variables" {
4042
($object2 | Select-PSFObject -Property 'Tara from object').Tara | Should -Be 21
4143
}
4244

4345
It "picks values from the properties of the right object in a list" {
4446
($object2 | Select-PSFObject -Property 'Tara from List where Foo = Bar').Tara | Should -Be 28
4547
}
4648
}
47-
49+
50+
Describe "Selects from other non-object variables" {
51+
It "picks values from other non-object variables" {
52+
($object2 | Select-PSFObject -Property '$variable as Tara').Tara | Should -Be 42
53+
}
54+
It "uses the variable name as property name" {
55+
($object2 | Select-PSFObject -Property '$variable').variable | Should -Be 42
56+
}
57+
}
58+
4859
Describe "Display Settings are applied" {
4960
It "sets the correct properties to show in whitelist mode" {
5061
$obj = [PSCustomObject]@{ Foo = "Bar"; Bar = 42; Right = "Left" }

0 commit comments

Comments
 (0)