{-# LANGUAGE QuasiQuotes, OverloadedStrings, UnicodeSyntax #-} module Data.IndieWeb.MicroformatsToAtomSpec where import Test.Hspec import TestCommon import Text.XML import Data.Text.Lazy (Text, unpack) import Data.Aeson hiding (json) import Data.IndieWeb.MicroformatsToAtom ex ∷ Value ex = [json|{ "items": [ { "type": [ "h-entry" ], "properties": { "published": [ "2016-03-15T21:03:52.570481000000Z" ], "url": [ "https://unrelenting.technology/notes/2016-03-15-21-03-52" ], "content": [ { "value": "Updated the build of sweetroll on this website", "html": " \u003cp\u003eUpdated the build of \u003ca href=\"https://codeberg.org/valpackett/sweetroll\"\u003esweetroll\u003c/a\u003e on this website \u003c/p\u003e\u003ca href=\"https://brid.gy/publish/twitter\"\u003e\u003c/a\u003e " } ], "name": [ "Updated the build of sweetroll on this website" ] } }, { "type": [ "h-entry" ], "properties": { "published": [ "2016-03-14T22:23:11.089Z" ], "url": [ "https://unrelenting.technology/responses/reply" ], "content": [ { "value": "(Reply test)", "html": " \u003cp\u003e(Reply test)\u003c/p\u003e" } ], "name": [ "(Reply test)" ], "in-reply-to": [ { "type": [ "h-entry" ], "properties": { "url": [ "https://unrelenting.technology/responses/parent" ] } } ] } }, { "type": [ "h-entry" ], "properties": { "published": [ "2016-03-14T22:23:11.089Z" ], "url": [ "https://unrelenting.technology/notes/repost" ], "content": [ { "value": "(Repost test)", "html": " \u003cp\u003e(Repost test)\u003c/p\u003e" } ], "name": [ "(Repost test)" ], "repost-of": [ { "type": [ "h-entry" ], "properties": { "published": [ "2016-03-14T22:23:11.089Z" ], "url": [ "https://unrelenting.technology/notes/original" ], "content": [ { "value": "(Repost original)", "html": " \u003cp\u003e(Repost original)\u003c/p\u003e" } ], "name": [ "(Repost original)" ] } } ] } }, { "type": [ "h-card" ], "properties": { "name": [ "Greg" ], "email": [ "mailto:val@packett.cool" ], "photo": [ "https://www.gravatar.com/avatar/5e7281cf21d93c6a238749790afe086c" ], "note": [ "My name's Greg. I do a lot of software development (mostly web and mobile), some design and photography. my.pronoun.is/they/them." ], "url": [ "https://unrelenting.technology/" ], "key": [ "https://unrelenting.technology/pub/3B011BAF.asc" ], "x-pronoun-oblique": [ "them" ], "x-pronoun-nominative": [ "they" ] } } ], "rels": { "home": [ "https://unrelenting.technology/" ], "author": [ "https://unrelenting.technology/" ] }, "rel-urls": { "https://unrelenting.technology/": { "text": "Greg", "rels": [ "me", "home", "author" ] } } } |] exAtom ∷ Text exAtom = [xml| Greg https://unrelenting.technology/ val@packett.cool http://activitystrea.ms/schema/1.0/person https://www.gravatar.com/avatar/5e7281cf21d93c6a238749790afe086c https://unrelenting.technology/notes/2016-03-15-21-03-52 Updated the build of sweetroll on this website 2016-03-15T21:03:52.570481000000Z \u003cp\u003eUpdated the build of \u003ca href="https://codeberg.org/valpackett/sweetroll"\u003esweetroll\u003c/a\u003e on this website \u003c/p\u003e\u003ca href="https://brid.gy/publish/twitter"\u003e\u003c/a\u003e post http://activitystrea.ms/schema/1.0/note https://unrelenting.technology/responses/reply (Reply test) 2016-03-14T22:23:11.089Z \u003cp\u003e(Reply test)\u003c/p\u003e post http://activitystrea.ms/schema/1.0/comment https://unrelenting.technology/notes/repost (Repost test) 2016-03-14T22:23:11.089Z \u003cp\u003e(Repost test)\u003c/p\u003e share http://activitystrea.ms/schema/1.0/activity https://unrelenting.technology/notes/original (Repost original) 2016-03-14T22:23:11.089Z \u003cp\u003e(Repost original)\u003c/p\u003e post http://activitystrea.ms/schema/1.0/note |] spec ∷ Spec spec = do describe "feedToAtom" $ do it "converts h-entries to an Atom feed" $ do --feedToAtom empty ex `shouldBe` parseText_ def exAtom --putStrLn $ unpack $ renderText def $ feedToAtom empty ex pendingWith "XML comparison sucks because of whitespace nodes and namespaces"