~jaro/balkon

ref: 044087b89fc2ea4be8eef813b263f2ab09d903df balkon/test/Data/Text/ParagraphLayout/RunSpec.hs -rw-r--r-- 1.6 KiB
044087b8Jaro Automatically discover test specs. 1 year, 8 months ago
                                                                                
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Data.Text.ParagraphLayout.RunSpec (spec) where

import Data.Text.Glyphize (Direction(..))
import Data.Text.Lazy (pack)

import Test.Hspec
import Data.Text.ParagraphLayout
import Data.Text.ParagraphLayout.FontLoader
import Data.Text.ParagraphLayout.Run
import Data.Text.ParagraphLayout.SpanData

spec :: Spec
spec = do
    describe "spanToRuns" $ before loadUbuntuRegular $ do
        it "handles span with no text" $ \font -> do
            spanToRuns (emptySpan font) `shouldBe` []
        it "handles Czech hello" $ \font -> do
            let inputSpan = czechHello font
            let runs = spanToRuns inputSpan
            runs `shouldBe`
                [ Run
                    { runText = spanText inputSpan
                    , runDirection = Just DirLTR
                    , runScript = Just "Latn"
                    , runOriginalSpan = inputSpan
                    }
                ]
        it "handles Serbian with mixed script" $ \font -> do
            let inputSpan = serbianMixedScript font
            let runs = spanToRuns inputSpan
            runs `shouldBe`
                [ Run
                    -- TODO: We might want both parentheses in the same run.
                    { runText = pack "Vikipedija ("
                    , runDirection = Just DirLTR
                    , runScript = Just "Latn"
                    , runOriginalSpan = inputSpan
                    }
                , Run
                    { runText = pack "Википедија)"
                    , runDirection = Just DirLTR
                    , runScript = Just "Cyrl"
                    , runOriginalSpan = inputSpan
                    }
                ]