@@ -13,7 +13,7 @@ defmodule MastaniServer.Test.Query.PagedPostsTest do
13
13
14
14
@ cur_date Timex . now ( )
15
15
@ last_week Timex . shift ( Timex . beginning_of_week ( @ cur_date ) , days: - 1 )
16
- @ last_month Timex . shift ( Timex . beginning_of_month ( @ cur_date ) , days: - 1 )
16
+ @ last_month Timex . shift ( Timex . beginning_of_month ( @ cur_date ) , days: - 2 )
17
17
@ last_year Timex . shift ( Timex . beginning_of_year ( @ cur_date ) , days: - 1 )
18
18
19
19
@ posts_today_count 35
@@ -166,17 +166,31 @@ defmodule MastaniServer.Test.Query.PagedPostsTest do
166
166
assert results |> Map . get ( "totalCount" ) == expect_count
167
167
end
168
168
169
+ @ tag :wip
169
170
test "THIS_WEEK option should work" , ~m( guest_conn) a do
170
171
variables = % { filter: % { when: "THIS_WEEK" } }
171
172
results = guest_conn |> query_result ( @ query , variables , "pagedPosts" )
173
+
172
174
assert results |> Map . get ( "totalCount" ) == @ posts_today_count
173
175
end
174
176
175
177
test "THIS_MONTH option should work" , ~m( guest_conn) a do
176
178
variables = % { filter: % { when: "THIS_MONTH" } }
177
179
results = guest_conn |> query_result ( @ query , variables , "pagedPosts" )
178
180
179
- expect_count = @ posts_total_count - @ posts_last_year_count - @ posts_last_month_count
181
+ { _ , cur_week_month , _ } = @ cur_date |> Date . to_erl ( )
182
+ { _ , last_week_month , _ } = @ last_week |> Date . to_erl ( )
183
+
184
+ expect_count =
185
+ case cur_week_month == last_week_month do
186
+ true ->
187
+ @ posts_total_count - @ posts_last_year_count - @ posts_last_month_count
188
+
189
+ false ->
190
+ @ posts_total_count - @ posts_last_year_count - @ posts_last_month_count -
191
+ @ posts_last_week_count
192
+ end
193
+
180
194
assert results |> Map . get ( "totalCount" ) == expect_count
181
195
end
182
196
end