Skip to content

Commit

Permalink
Merge pull request #176 from leojonathanoh/fix/tests-ensure-interacti…
Browse files Browse the repository at this point in the history
…ve-configuration-uses-default-values-when-empty-values-are-passed

Fix (tests): Ensure interactive configuration uses default values when empty values are passed
  • Loading branch information
leojonathanoh authored Nov 20, 2023
2 parents d2a3100 + 60be08e commit 49cdd73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
12 changes: 3 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,19 @@
"label": "Test (pwsh)",
"type": "shell",
"command": "pwsh -Command test/test.ps1",
"group": {
"isDefault": true,
"kind": "test"
}
"group": "build",
},
{
"label": "Test (powershell)",
"type": "shell",
"command": "powershell -Command test/test.ps1",
"group": {
"isDefault": true,
"kind": "test"
}
"group": "build",
},
{
"label": "Generate config.example.ps1",
"type": "shell",
"command": "pwsh -Command '. ./ConvertOneNote2MarkDown-v2.ps1 -Exit; New-ConfigurationFile'",
"group": "build"
"group": "build",
},
{
"label": "Convert",
Expand Down
15 changes: 13 additions & 2 deletions ConvertOneNote2MarkDown-v2.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,21 @@ $newlineCharacter = 1

It "Compiles configuration from interactive prompts: cast input as expected type, and fallback on default values on empty input" {
$fakeUserInputs = Get-DefaultConfiguration
$fakeUserInputs['dryRun']['value'] = '' # Should fallback on default value
$fakeUserInputs['notesdestpath']['value'] = 'c:\foo\bar' # Should be intact
$fakeUserInputs['targetNotebook']['value'] = $null # Should fallback on default value
$fakeUserInputs['usedocx']['value'] = '1' # Should be casted to an int
$fakeUserInputs['targetNotebook']['value'] = '' # Should fallback on default value
$fakeUserInputs['usedocx']['value'] = '0' # Should be casted to an int
$fakeUserInputs['keepdocx']['value'] = $null # Should fallback on default value
$fakeUserInputs['docxNamingConvention']['value'] = '' # Should fallback on default value ...
$fakeUserInputs['prefixFolders']['value'] = ''
$fakeUserInputs['mdFileNameAndFolderNameMaxLength']['value'] = ''
$fakeUserInputs['medialocation']['value'] = ''
$fakeUserInputs['conversion']['value'] = ''
$fakeUserInputs['headerTimestampEnabled']['value'] = ''
$fakeUserInputs['keepspaces']['value'] = ''
$fakeUserInputs['keepescape']['value'] = ''
$fakeUserInputs['newlineCharacter']['value'] = ''
$fakeUserInputs['exportPdf']['value'] = ''
Mock Test-Path { $false }
Mock Read-Host {
$typeName = [Microsoft.PowerShell.ToStringCodeMethods]::Type($config[$key]['default'].GetType())
Expand Down

0 comments on commit 49cdd73

Please sign in to comment.