chore: add spec test for keycard component (#15920)

This commit is contained in:
Jamie Caprani 2023-05-19 12:45:47 +01:00 committed by GitHub
parent 62945205a0
commit 77ddd8688f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 15 deletions

View File

@ -1,20 +1,11 @@
(ns quo2.components.keycard.component-spec
(:require [quo2.components.keycard.view :as keycard]
[test-helpers.component :as h]
[utils.i18n :as i18n]))
[test-helpers.component :as h]))
(h/describe "keycard component"
(h/test "Render of keycard component when: Status = Empty, Locked = False"
(h/test "Render of keycard component when: holder-name prop is not set"
(h/render [keycard/keycard])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/empty-keycard))))
(h/test "Render of keycard component when: Status = Filled, Locked = False"
(h/render [keycard/keycard {:holder-name? "Alisha"}])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/user-keycard {:name :holder-name}))))
(h/test "Render of keycard component when: Status = Filled, Locked = True"
(h/render [keycard/keycard {:holder-name? "Alisha"}])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/user-keycard {:name :holder-name})))))
(h/is-truthy (h/get-by-translation-text :empty-keycard)))
(h/test "Render of keycard component when: holder-name prop is set"
(h/render [keycard/keycard {:holder-name "Alisha"}])
(h/is-truthy (h/get-by-translation-text :user-keycard))))

View File

@ -14,6 +14,7 @@
[quo2.components.drawers.drawer-buttons.component-spec]
[quo2.components.drawers.permission-context.component-spec]
[quo2.components.inputs.input.component-spec]
[quo2.components.keycard.component-spec]
[quo2.components.inputs.profile-input.component-spec]
[quo2.components.inputs.recovery-phrase.component-spec]
[quo2.components.inputs.title-input.component-spec]

View File

@ -188,6 +188,10 @@
[element]
(.toBeTruthy (js/expect element)))
(defn is-falsy
[element]
(.toBeFalsy (js/expect element)))
(defn is-null
[element]
(.toBeNull (js/expect element)))