Skip to content

Commit 50578fa

Browse files
author
James Brundage
committed
Adding Search-PipeScript tests
1 parent 08b1456 commit 50578fa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Search-PipeScript.tests.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
describe Search-PipeScript {
2+
context 'Searching PowerShell' {
3+
it 'Can search for AST types within a ScriptBlock' {
4+
{
5+
"hello world $message"
6+
} | Search-PipeScript -AstType variable |
7+
Select-Object -ExpandProperty Result |
8+
Should -Be '$message'
9+
}
10+
11+
it 'Can search within an AST' {
12+
{
13+
"hello world $message"
14+
}.Ast |
15+
Search-PipeScript -AstType variable |
16+
Select-Object -ExpandProperty result |
17+
Should -Be '$message'
18+
}
19+
}
20+
21+
context 'Searching text' {
22+
it 'Can search text, too' {
23+
'123' |
24+
Search-PipeScript -RegularExpression '\d+' |
25+
Select-Object -ExpandProperty Result |
26+
Should -Be '123'
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)