@@ -182,7 +182,7 @@ Describe "Get-BloggerPost" {
182182 return @ {
183183 id = $postId
184184 title = " Test Post"
185- published = " 10/01/ 2023 12:00 :00"
185+ published = [ datetime ] " 2023-10-01T17:30:00-04 :00"
186186 content = " <h1>Hello World</h1><p>This is a post.</p>"
187187 }
188188 }
@@ -211,6 +211,51 @@ Describe "Get-BloggerPost" {
211211 }
212212 }
213213
214+ Context " As Json" {
215+ BeforeEach {
216+ InModuleScope PSBlogger {
217+ # Mock the session to return a test blog ID
218+ $BloggerSession.BlogId = " test-blog-id"
219+
220+ $postId = " 123"
221+
222+ # mock post retrieval
223+ Mock Invoke-GApi {
224+ return @ {
225+ id = $postId
226+ title = " Test Post"
227+ published = [datetime ]" 2023-10-01T17:30:00-04:00"
228+ content = " <h1>Hello World</h1><p>This is a post.</p>"
229+ }
230+ }
231+ }
232+
233+ $postId = " 123"
234+ $title = " Test Post"
235+ $outFile = " TestDrive:\$postId .json"
236+
237+ }
238+
239+ AfterEach {
240+ if (Test-Path $outFile ) {
241+ Remove-Item $outFile - Force
242+ }
243+ }
244+
245+ It " Should write json response to file" {
246+
247+ # act
248+ Get-BloggerPost - PostId $postId - Format JSON - OutDirectory " TestDrive:\"
249+
250+ # assert
251+ $jsonContent = Get-Content - Path $outFile - Raw | ConvertFrom-Json
252+ $jsonContent.id | Should - Be " 123"
253+ $jsonContent.title | Should - Be " Test Post"
254+ $jsonContent.content | Should -Not - BeNullOrEmpty
255+ $jsonContent.published | Should -Not - BeNullOrEmpty
256+ }
257+ }
258+
214259 Context " Using FolderDateFormat" {
215260
216261 BeforeEach {
@@ -225,7 +270,7 @@ Describe "Get-BloggerPost" {
225270 return @ {
226271 id = $postId
227272 title = " Test Post"
228- published = [datetime ]" 10/01/ 2023 12:00 :00"
273+ published = [datetime ]" 2023-10-01T17:30:00-04 :00"
229274 content = " <h1>Hello World</h1><p>This is a post.</p>"
230275 }
231276 }
0 commit comments