-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathConvertFromNotebookToMarkdown.tests.ps1
More file actions
49 lines (32 loc) · 1.82 KB
/
ConvertFromNotebookToMarkdown.tests.ps1
File metadata and controls
49 lines (32 loc) · 1.82 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
Import-Module $PSScriptRoot\..\PowerShellNotebook.psd1 -Force
Describe "Test ConvertFrom-NoteBookToMarkdown" {
It "Should convert to markdown" {
$targetFile = "$PSScriptRoot\GoodNotebooks\SimpleNotebookToTestConvertToMarkdown.ipynb"
$actual = ConvertFrom-NoteBookToMarkdown -NotebookName $targetFile -AsText
$actual.Count | Should -Be 3
$actual[0].trim() | Should -Beexactly '# Test for converting a PS Notebook to Markdown'
$actual[2].trim() | Should -Beexactly '## End of PS Notebook'
($actual[1]).StartsWith('```powershell') | Should -Be $true
($actual[1]).Trim().EndsWith('```') | Should -Be $true
}
It "Should convert to markdown in a file" {
$targetFile = "$PSScriptRoot\GoodNotebooks\SimpleNotebookToTestConvertToMarkdown.ipynb"
$mdFile = "$PSScriptRoot\GoodNotebooks\SimpleNotebookToTestConvertToMarkdown.md"
$expected = Split-Path $mdFile -Leaf
$actual = ConvertFrom-NoteBookToMarkdown -NotebookName $targetFile
$actual | Should -Beexactly $expected
Remove-Item $expected -ErrorAction SilentlyContinue
}
It "Should remove the #!pwsh shebang in code blocks" {
$targetFile = "$PSScriptRoot\DotNetInteractiveNotebooks\PwshShebangTest.ipynb"
$actual = ConvertFrom-NotebookToMarkdown -NotebookName $targetFile -AsText
$powerShellCodeBlock = $actual[1]
$powerShellCodeBlock.Split("`n") | Should -Not -Contain "#!pwsh"
}
It "Should not remove the #!pwsh shebang in markdown blocks" {
$targetFile = "$PSScriptRoot\DotNetInteractiveNotebooks\PwshShebangTest.ipynb"
$actual = ConvertFrom-NotebookToMarkdown -NotebookName $targetFile -AsText
$markDownBlock = $actual[2]
$markDownBlock.Split("`n") | Should -Contain "#!pwsh"
}
}