aboutsummaryrefslogtreecommitdiff
path: root/specs
diff options
context:
space:
mode:
Diffstat (limited to 'specs')
-rw-r--r--specs/Specs/ViewSpec.hs30
1 files changed, 19 insertions, 11 deletions
diff --git a/specs/Specs/ViewSpec.hs b/specs/Specs/ViewSpec.hs
index 9d7dfda..13d4a9f 100644
--- a/specs/Specs/ViewSpec.hs
+++ b/specs/Specs/ViewSpec.hs
@@ -12,6 +12,11 @@ test = do
let defaultState = def {stateGridRows = 2, stateGridCols = 2, stateMode = ModeHints def {stateGrid = [["ABC", "DEF"], ["DJK", "JKL"]]}}
describe "#render" $ do
+ let drawTextCalls mock =
+ filter
+ (\(CallWrapper c) -> case c of Mock_drawText {} -> True; _ -> False)
+ $ calls mock
+
context "when key sequence is empty" $ do
let currentState = defaultState {stateMode = ModeHints (modeHintsData $ stateMode defaultState) {stateKeySequence = ""}}
@@ -19,10 +24,11 @@ test = do
(_, mock) <- runWithMocks $ do
Mock_windowSize `mockReturns` mockWindowSize
render currentState
- mock `shouldHaveCalled` Mock_drawText (460, 10) (hintLabelTextStyle {textColor = colorWhite}) "ABC"
- mock `shouldHaveCalled` Mock_drawText (1420, 10) (hintLabelTextStyle {textColor = colorWhite}) "DEF"
- mock `shouldHaveCalled` Mock_drawText (460, 550) (hintLabelTextStyle {textColor = colorWhite}) "DJK"
- mock `shouldHaveCalled` Mock_drawText (1420, 550) (hintLabelTextStyle {textColor = colorWhite}) "JKL"
+ mock `shouldHaveCalled` Mock_drawText (464, 20) (hintLabelTextStyle {textColor = colorWhite}) "ABC"
+ mock `shouldHaveCalled` Mock_drawText (1424, 20) (hintLabelTextStyle {textColor = colorWhite}) "DEF"
+ mock `shouldHaveCalled` Mock_drawText (464, 560) (hintLabelTextStyle {textColor = colorWhite}) "DJK"
+ mock `shouldHaveCalled` Mock_drawText (1424, 560) (hintLabelTextStyle {textColor = colorWhite}) "JKL"
+ length (drawTextCalls mock) `shouldBe` 4
context "when there is a partial match" $ do
let currentState = defaultState {stateMode = ModeHints (modeHintsData $ stateMode defaultState) {stateKeySequence = "D"}}
@@ -30,13 +36,14 @@ test = do
it "draws matching text labels" $ do
(_, mock) <- runWithMocks $ do
Mock_windowSize `mockReturns` mockWindowSize
- Mock_drawText (1420, 10) (hintLabelTextStyle {textColor = colorLightGray}) "D" `mockReturns` (10, 0)
- Mock_drawText (460, 550) (hintLabelTextStyle {textColor = colorLightGray}) "D" `mockReturns` (10, 0)
+ Mock_drawText (1424, 20) (hintLabelTextStyle {textColor = colorLightGray}) "D" `mockReturns` (10, 0)
+ Mock_drawText (464, 560) (hintLabelTextStyle {textColor = colorLightGray}) "D" `mockReturns` (10, 0)
render currentState
- mock `shouldHaveCalled` Mock_drawText (1420, 10) (hintLabelTextStyle {textColor = colorLightGray}) "D"
- mock `shouldHaveCalled` Mock_drawText (1430, 10) (hintLabelTextStyle {textColor = colorAccent}) "EF"
- mock `shouldHaveCalled` Mock_drawText (460, 550) (hintLabelTextStyle {textColor = colorLightGray}) "D"
- mock `shouldHaveCalled` Mock_drawText (470, 550) (hintLabelTextStyle {textColor = colorAccent}) "JK"
+ mock `shouldHaveCalled` Mock_drawText (1424, 20) (hintLabelTextStyle {textColor = colorLightGray}) "D"
+ mock `shouldHaveCalled` Mock_drawText (1434, 20) (hintLabelTextStyle {textColor = colorAccent}) "EF"
+ mock `shouldHaveCalled` Mock_drawText (464, 560) (hintLabelTextStyle {textColor = colorLightGray}) "D"
+ mock `shouldHaveCalled` Mock_drawText (474, 560) (hintLabelTextStyle {textColor = colorAccent}) "JK"
+ length (drawTextCalls mock) `shouldBe` 4
context "when key sequence is complete match" $ do
let currentState = defaultState {stateMode = ModeHints (modeHintsData $ stateMode defaultState) {stateKeySequence = "DEF"}}
@@ -45,7 +52,8 @@ test = do
(_, mock) <- runWithMocks $ do
Mock_windowSize `mockReturns` mockWindowSize
render currentState
- mock `shouldHaveCalled` Mock_drawText (1420, 10) (hintLabelTextStyle {textColor = colorLightGray}) "DEF"
+ mock `shouldHaveCalled` Mock_drawText (1424, 20) (hintLabelTextStyle {textColor = colorLightGray}) "DEF"
+ length (drawTextCalls mock) `shouldBe` 1
describe "#renderKeySequence" $ do
context "when there is a partial match" $ do