packages feed

nostr-1.3.0.0: test/Test/Nostr/Nip21Spec.hs

{-# LANGUAGE OverloadedStrings #-}

module Test.Nostr.Nip21Spec (spec) where

import Test.Hspec
import Nostr.Nip21
import Data.Either (isRight, isLeft)

spec :: Spec
spec = do
  describe "Nostr.Nip21" $ do
    it "parses nostr: URIs" $ do
      let uri = "nostr:npub1sg6plzptd64u62a878hep2kev88swjh3tw00gjsfl8f237lmu63q0uf63m"
      parseNostrUri uri `shouldSatisfy` isRight
      
    it "handles URIs without scheme" $ do
      parseNostrUri "npub1sg6plzptd64u62a878hep2kev88swjh3tw00gjsfl8f237lmu63q0uf63m" `shouldSatisfy` isLeft
      
    it "rejects arbitrary strings" $ do
      parseNostrUri "hello world" `shouldSatisfy` isLeft