From 1bd86a46dcf21a75656edd181f97035739fa238d Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 28 Dec 2024 22:14:05 +0530 Subject: Refactor text styles --- specs/Specs/ViewSpec.hs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'specs') diff --git a/specs/Specs/ViewSpec.hs b/specs/Specs/ViewSpec.hs index a5a67c9..9d7dfda 100644 --- a/specs/Specs/ViewSpec.hs +++ b/specs/Specs/ViewSpec.hs @@ -19,10 +19,10 @@ test = do (_, mock) <- runWithMocks $ do Mock_windowSize `mockReturns` mockWindowSize render currentState - mock `shouldHaveCalled` Mock_drawText (460, 10) colorWhite FontLG "ABC" - mock `shouldHaveCalled` Mock_drawText (1420, 10) colorWhite FontLG "DEF" - mock `shouldHaveCalled` Mock_drawText (460, 550) colorWhite FontLG "DJK" - mock `shouldHaveCalled` Mock_drawText (1420, 550) colorWhite FontLG "JKL" + 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" context "when there is a partial match" $ do let currentState = defaultState {stateMode = ModeHints (modeHintsData $ stateMode defaultState) {stateKeySequence = "D"}} @@ -30,13 +30,13 @@ test = do it "draws matching text labels" $ do (_, mock) <- runWithMocks $ do Mock_windowSize `mockReturns` mockWindowSize - Mock_drawText (1420, 10) colorLightGray FontLG "D" `mockReturns` (10, 0) - Mock_drawText (460, 550) colorLightGray FontLG "D" `mockReturns` (10, 0) + Mock_drawText (1420, 10) (hintLabelTextStyle {textColor = colorLightGray}) "D" `mockReturns` (10, 0) + Mock_drawText (460, 550) (hintLabelTextStyle {textColor = colorLightGray}) "D" `mockReturns` (10, 0) render currentState - mock `shouldHaveCalled` Mock_drawText (1420, 10) colorLightGray FontLG "D" - mock `shouldHaveCalled` Mock_drawText (1430, 10) colorAccent FontLG "EF" - mock `shouldHaveCalled` Mock_drawText (460, 550) colorLightGray FontLG "D" - mock `shouldHaveCalled` Mock_drawText (470, 550) colorAccent FontLG "JK" + 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" context "when key sequence is complete match" $ do let currentState = defaultState {stateMode = ModeHints (modeHintsData $ stateMode defaultState) {stateKeySequence = "DEF"}} @@ -45,17 +45,17 @@ test = do (_, mock) <- runWithMocks $ do Mock_windowSize `mockReturns` mockWindowSize render currentState - mock `shouldHaveCalled` Mock_drawText (1420, 10) colorLightGray FontLG "DEF" + mock `shouldHaveCalled` Mock_drawText (1420, 10) (hintLabelTextStyle {textColor = colorLightGray}) "DEF" describe "#renderKeySequence" $ do context "when there is a partial match" $ do it "draws the matched section and highlights the remaining characters" $ do (_, mock) <- runWithMocks $ do Mock_windowSize `mockReturns` mockWindowSize - Mock_drawText (0, 0) colorLightGray FontLG "ABC" `mockReturns` (30, 0) + Mock_drawText (0, 0) (hintLabelTextStyle {textColor = colorLightGray}) "ABC" `mockReturns` (30, 0) renderKeySequence "ABC" "ABCDE" (0, 0) - mock `shouldHaveCalled` Mock_drawText (0, 0) colorLightGray FontLG "ABC" - mock `shouldHaveCalled` Mock_drawText (30, 0) colorAccent FontLG "DE" + mock `shouldHaveCalled` Mock_drawText (0, 0) (hintLabelTextStyle {textColor = colorLightGray}) "ABC" + mock `shouldHaveCalled` Mock_drawText (30, 0) (hintLabelTextStyle {textColor = colorAccent}) "DE" it "return true as the text is visible" $ do (isVisible, _) <- runWithMocks $ renderKeySequence "ABC" "ABCDE" (0, 0) @@ -64,7 +64,7 @@ test = do context "when there is no input key sequence" $ do it "draws text as a single chunk" $ do (_, mock) <- runWithMocks $ renderKeySequence "" "ABCD" (0, 0) - mock `shouldHaveCalled` Mock_drawText (0, 0) colorWhite FontLG "ABCD" + mock `shouldHaveCalled` Mock_drawText (0, 0) (hintLabelTextStyle {textColor = colorWhite}) "ABCD" it "return true as the text is visible" $ do (isVisible, _) <- runWithMocks $ renderKeySequence "" "ABCD" (0, 0) -- cgit v1.3.1