@@ -42,5 +42,84 @@ Describe "Get-BloggerPosts" {
4242 # assert
4343 $result.Count | Should - Be 3
4444 }
45+
46+ It " Should only fetch initial set if -All switch is not used" {
47+ # arrange
48+ InModuleScope PSBlogger {
49+ # Setup initial get-bloggerposts
50+ Mock Invoke-GApi {
51+ return @ {
52+ items = @ (
53+ @ { id = " 1" ; title = " Post 1" ; published = " 2023-10-01T00:00:00Z" },
54+ @ { id = " 2" ; title = " Post 2" ; published = " 2023-10-02T00:00:00Z" }
55+ )
56+ nextPageToken = $null
57+ }
58+ } - ParameterFilter { $uri -notlike " *pageToken*" }
59+ }
60+
61+ # act
62+ $result = Get-BloggerPosts - All
63+
64+ # assert
65+ $result.Count | Should - Be 2
66+ }
67+ }
68+
69+ Context " Retrieve Posts with Date Filter" {
70+ BeforeEach {
71+ InModuleScope PSBlogger {
72+
73+ $BloggerSession.BlogId = " 123456789"
74+ }
75+ }
76+
77+ It " Should filter posts based on Since parameter" {
78+ # arrange
79+ InModuleScope PSBlogger {
80+
81+ # Mock the API call to return posts after a specific date
82+ Mock Invoke-GApi {
83+ return @ {
84+ items = @ (
85+ @ { id = " 1" ; title = " Post 1" ; published = " 2023-10-01T00:00:00Z" },
86+ @ { id = " 2" ; title = " Post 2" ; published = " 2023-10-02T00:00:00Z" }
87+ )
88+ nextPageToken = $null
89+ }
90+ } - ParameterFilter { $uri -like " *since=2023-09-30*" }
91+ }
92+
93+ # act
94+ $result = Get-BloggerPosts - Since (Get-Date " 2023-09-30" )
95+
96+ # assert
97+ $result.Count | Should - Be 2
98+ $result [0 ].title | Should - Be " Post 1"
99+ $result [1 ].title | Should - Be " Post 2"
100+ }
101+
102+ It " Should not constrain by date if Since parameter is not provided" {
103+ # arrange
104+ InModuleScope PSBlogger {
105+
106+ # Mock the API call to return all posts
107+ Mock Invoke-GApi {
108+ return @ {
109+ items = @ (
110+ @ { id = " 1" ; title = " Post 1" ; published = " 2023-10-01T00:00:00Z" },
111+ @ { id = " 2" ; title = " Post 2" ; published = " 2023-10-02T00:00:00Z" }
112+ )
113+ nextPageToken = $null
114+ }
115+ } - ParameterFilter { $uri -notlike " *since*" }
116+ }
117+
118+ # act
119+ $result = Get-BloggerPosts
120+
121+ # assert
122+ $result.Count | Should - Be 2
123+ }
45124 }
46125}
0 commit comments