telegram-api 0.4.0.0 → 0.4.0.1
raw patch · 4 files changed
+91/−3 lines, 4 files
Files
- CHANGELOG.md +6/−0
- src/Web/Telegram/API/Bot/Responses.hs +2/−2
- telegram-api.cabal +2/−1
- test/JsonSpec.hs +81/−0
CHANGELOG.md view
@@ -1,3 +1,9 @@+## 0.4.0.1++Bugfixes:++* Parsing issue with answer callback query response+ ## 0.4.0.0 [Breaking] Features:
src/Web/Telegram/API/Bot/Responses.hs view
@@ -136,10 +136,10 @@ } deriving (Show, Generic) instance ToJSON CallbackQueryResponse where- toJSON = toJsonDrop 7+ toJSON = toJsonDrop 9 instance FromJSON CallbackQueryResponse where- parseJSON = parseJsonDrop 7+ parseJSON = parseJsonDrop 9 -- | This object represents 'kickChatMember' response data KickChatMemberResponse = KickChatMemberResponse
telegram-api.cabal view
@@ -1,5 +1,5 @@ name: telegram-api-version: 0.4.0.0+version: 0.4.0.1 synopsis: Telegram Bot API bindings description: High-level bindings to the Telegram Bot API homepage: http://github.com/klappvisor/haskell-telegram-api#readme@@ -49,6 +49,7 @@ main-is: Spec.hs other-modules: MainSpec , InlineSpec+ , JsonSpec build-depends: base , aeson , hjpath
+ test/JsonSpec.hs view
@@ -0,0 +1,81 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE TemplateHaskell #-}++module JsonSpec (spec) where++import Control.Monad+import Web.Telegram.API.Bot+import Test.Hspec+import Data.Text (Text)+import qualified Data.Text as T+import System.Environment+import Data.Aeson.Encode+import Text.JSON.JPath+import Data.ByteString.Lazy.UTF8++spec :: Spec+spec = do+ let getType = \q -> jPath (T.unpack "type") (toString (encode q))+ describe "type of serialized inline query result" $ do+ it "should be article" $ do+ (getType iq_article) `shouldBe` ["\"article\""]+ it "should be photo" $ do+ (getType iq_photo) `shouldBe` ["\"photo\""]+ it "should be gif" $ do+ (getType iq_gif) `shouldBe` ["\"gif\""]+ it "should be mpeg4_gif" $ do+ (getType iq_mpeg) `shouldBe` ["\"mpeg4_gif\""]+ it "should be video" $ do+ (getType iq_video) `shouldBe` ["\"video\""]+ it "should be audio" $ do+ (getType iq_audio) `shouldBe` ["\"audio\""]+ it "should be contact" $ do+ (getType iq_contact) `shouldBe` ["\"contact\""]+ it "should be document" $ do+ (getType iq_document) `shouldBe` ["\"document\""]+ it "should be location" $ do+ (getType iq_location) `shouldBe` ["\"location\""]+ it "should be venue" $ do+ (getType iq_venue) `shouldBe` ["\"venue\""]+ describe "type of serialized cached inline query result" $ do+ it "should be audio" $ do+ (getType cached_audio) `shouldBe` ["\"audio\""]+ it "should be voice" $ do+ (getType cached_voice) `shouldBe` ["\"voice\""]+ it "should be video" $ do+ (getType cached_video) `shouldBe` ["\"video\""]+ it "should be document" $ do+ (getType cached_doc) `shouldBe` ["\"document\""]+ it "should be sticker" $ do+ (getType cached_sticker) `shouldBe` ["\"sticker\""]+ it "should be mpeg4_gif" $ do+ (getType cached_mpeg) `shouldBe` ["\"mpeg4_gif\""]+ it "should be gif" $ do+ (getType cached_gif) `shouldBe` ["\"gif\""]+ it "should be photo" $ do+ (getType cached_photo) `shouldBe` ["\"photo\""]++message_content = InputTextMessageContent "test message content" Nothing Nothing++iq_article = inlineQueryResultArticle "" "text article content" message_content+iq_photo = inlineQueryResultPhoto "" "" ""+iq_gif = inlineQueryResultGif "" "" ""+iq_mpeg = inlineQueryResultMpeg4Gif "" "" ""+iq_video = inlineQueryResultVideo "" "" "video/mpeg" "" ""+iq_audio = inlineQueryResultAudio "" "" ""+iq_contact = inlineQueryResultContact "" "" ""+iq_document = inlineQueryResultDocument "" "" "" ""+iq_location = inlineQueryResultLocation "" 0.0 0.0 ""+iq_venue = inlineQueryResultVenue "" 0.0 0.0 "" ""+cached_audio = inlineQueryResultCachedAudio "" ""+cached_voice = inlineQueryResultCachedVoice "" "" ""+cached_video = inlineQueryResultCachedVideo "" "" ""+cached_doc = inlineQueryResultCachedDocument "" "" ""+cached_sticker = inlineQueryResultCachedSticker "" ""+cached_mpeg = inlineQueryResultCachedMpeg4Gif "" ""+cached_gif = inlineQueryResultCachedGif "" ""+cached_photo = inlineQueryResultCachedPhoto "" ""