Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Test/public/newNotes.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ function Test_NewNote_Simple_WithDate{

}

function Test_NewNote_Simple_WithOutDate{

Reset-InvokeCommandMock

New-TestingFolder "TestNotesRoot"
MockCallToString 'Invoke-NotesHelperNotesRoot' -OutString "./TestNotesRoot"

$category = "TestClient"
$title = "This is the title of the note"

$header = "# {category} - {title} (NoDate)"
$header = $header -replace "{category}", $category
$header = $header -replace "{title}", $title

# Add note with date
$path = New-Note $category $title -NoOpen -Force -Date $date

$content = Get-Content -Path $path -Raw

Assert-IsTrue $content.StartsWith($header)

}

function Test_AddNotesToday_Simple_AddNoteFolder {

Reset-InvokeCommandMock
Expand Down
3 changes: 2 additions & 1 deletion public/newNotes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ function getFileContent{
# Replace placeholders in the template with actual values
$content = $content -replace '{title}' , $Title
$content = $content -replace '{header}' , $header
$content = $content -replace '{date}' , $Date

$content = $content -replace '{date}' , ([string]::IsNullOrWhiteSpace($Date) ? 'NoDate' : "$Date")
$content = $content -replace '{notes}' , ([string]::IsNullOrWhiteSpace($Notes) ? '-' : $Notes)
$content = $content -replace '{issueurl}' , ([string]::IsNullOrWhiteSpace($IssueUrl) ? '<IssueUrl>' : $IssueUrl)

Expand Down