Skip to content

Commit be42c28

Browse files
nvmdTristanCacqueray
authored andcommitted
Add m.reaction decode test
1 parent 5205fdf commit be42c28

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

test/Spec.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ spec = describe "unit tests" $ do
9696
mtBody srcMsg `shouldBe` " * > :typo"
9797
mtBody message `shouldBe` "> :hello"
9898
_ -> error $ show resp
99+
it "decode reaction" $ do
100+
resp <- decodeResp <$> BS.readFile "test/data/reaction.json"
101+
case resp of
102+
Right (Right (EventReaction eventID (Annotation annText))) -> do
103+
eventID `shouldBe` EventID "$eventID"
104+
annText `shouldBe` "\128077" -- :+1:
105+
_ -> error $ show resp
99106
it "encode room message" $
100107
encodePretty (RoomMessageText (MessageText "Hello" TextType Nothing Nothing))
101108
`shouldBe` "{\"body\":\"Hello\",\"msgtype\":\"m.text\"}"

test/data/reaction.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"m.relates_to": {
3+
"event_id": "$eventID",
4+
"key": "👍",
5+
"rel_type": "m.annotation"
6+
}
7+
}

0 commit comments

Comments
 (0)