summaryrefslogtreecommitdiff
path: root/tests/SlackBuilder/PackageSpec.hs
blob: ffe6737c2c601510cbc1c373eb48d31a9783b863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module SlackBuilder.PackageSpec
    ( spec
    ) where 

import Data.List.NonEmpty (NonEmpty(..))
import SlackBuilder.Package
import Test.Hspec (Spec, describe, it, shouldBe)
import Text.URI.QQ (uri)

spec :: Spec
spec = do
    describe "renderDownloadWithVersion" $ do
        it "renders text as URL" $
            let given = DownloadTemplate
                    $ pure
                    $ StaticPlaceholder "https://example.com"
                actual = renderDownloadWithVersion given "1.2"
                expected = Just [uri|https://example.com|]
             in actual `shouldBe` expected

        it "renders the components in order" $
            let given = DownloadTemplate
                    $ StaticPlaceholder "https://example.com/"
                    :| [VersionPlaceholder, StaticPlaceholder "/segment"]
                actual = renderDownloadWithVersion given "1.2"
                expected = Just [uri|https://example.com/1.2/segment|]
             in actual `shouldBe` expected