Skip to content

Commit 8fbff63

Browse files
committed
Add additional tests
1 parent 42780a6 commit 8fbff63

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

spec/Main.hs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,11 @@ cacheTests = do
331331
wpCacheGet' (view wordpress ctxt) key >>= shouldBe (Just (enc article1))
332332

333333
queryTests :: Spec
334-
queryTests =
334+
queryTests = do
335335
describe "generate queries from <wpPosts>" $ do
336336
"<wpPosts></wpPosts>" `shouldQueryTo`
337337
["/wp/v2/posts"]
338-
"<wpPosts orderby=\"title\" order=\"desc\"></wpPosts>" `shouldQueryTo`
339-
["/wp/v2/posts?order=desc&orderby=title"]
338+
describe "limit" $ do
340339
"<wpPosts limit=2></wpPosts>" `shouldQueryTo`
341340
["/wp/v2/posts"]
342341
"<wpPosts offset=1 limit=1></wpPosts>" `shouldQueryTo`
@@ -347,12 +346,14 @@ queryTests =
347346
["/wp/v2/posts?page=1"]
348347
"<wpPosts limit=10 page=2></wpPosts>" `shouldQueryTo`
349348
["/wp/v2/posts?page=2"]
349+
describe "num" $ do
350350
"<wpPosts num=2></wpPosts>" `shouldQueryTo`
351351
["/wp/v2/posts?per_page=2"]
352352
"<wpPosts num=2 page=2></wpPosts>" `shouldQueryTo`
353353
["/wp/v2/posts?page=2&per_page=2"]
354354
"<wpPosts num=1 page=3></wpPosts>" `shouldQueryTo`
355355
["/wp/v2/posts?page=3&per_page=1"]
356+
describe "taxonomies" $ do
356357
"<wpPosts tags=\"+home-featured\" limit=10></wpPosts>" `shouldQueryTo`
357358
["/wp/v2/posts?tags[]=177"]
358359
"<wpPosts tags=\"-home-featured\" limit=1></wpPosts>" `shouldQueryTo`
@@ -367,8 +368,32 @@ queryTests =
367368
["/wp/v2/posts?categories_exclude[]=159"]
368369
"<wp><div><wpPosts categories=\"bookmarx\" limit=10><wpTitle/></wpPosts></div></wp>" `shouldQueryTo`
369370
replicate 2 "/wp/v2/posts?categories[]=159"
371+
describe "pages" $ do
370372
"<wpPage name=blah />" `shouldQueryTo`
371373
["/wp/v2/pages?slug=blah"]
374+
describe "post filters" $ do
375+
"<wpPosts offset=10></wpPosts>" `shouldQueryTo`
376+
["/wp/v2/posts?offset=10"]
377+
"<wpPosts per-page=20></wpPosts>" `shouldQueryTo`
378+
["/wp/v2/posts?per_page=20"]
379+
"<wpPosts per-page=20 num=10></wpPosts>" `shouldQueryTo`
380+
["/wp/v2/posts?per_page=20"]
381+
"<wpPosts per-page=20 page=10></wpPosts>" `shouldQueryTo`
382+
["/wp/v2/posts?page=10&per_page=20"]
383+
"<wpPosts offset=10 num=5 page=5></wpPosts>" `shouldQueryTo`
384+
["/wp/v2/posts?offset=10&page=5&per_page=5"]
385+
"<wpPosts orderby=\"title\" order=\"desc\"></wpPosts>" `shouldQueryTo`
386+
["/wp/v2/posts?order=desc&orderby=title"]
387+
"<wpPosts before=\"2019-09-16 16:28:44.329789 UTC\"></wpPosts>" `shouldQueryTo`
388+
["/wp/v2/posts?before=2019-09-16T16:28:44Z"]
389+
"<wpPosts after=\"2019-09-16 16:28:44.329789 UTC\"></wpPosts>" `shouldQueryTo`
390+
["/wp/v2/posts?after=2019-09-16T16:28:44Z"]
391+
"<wpPosts search=\"gritty%20is%20a%20worker\"></wpPosts>" `shouldQueryTo`
392+
["/wp/v2/posts?search=gritty%20is%20a%20worker"]
393+
"<wpPosts status=draft></wpPosts>" `shouldQueryTo`
394+
["/wp/v2/posts?status=draft"]
395+
"<wpPosts sticky=true></wpPosts>" `shouldQueryTo`
396+
["/wp/v2/posts?sticky=true"]
372397

373398
liveTests :: Spec
374399
liveTests =

0 commit comments

Comments
 (0)