|
| 1 | +(ns quo.components.profile.collectible-list-item.component-spec |
| 2 | + (:require |
| 3 | + [quo.components.profile.collectible-list-item.view :as collectible-list-item] |
| 4 | + [test-helpers.component :as h])) |
| 5 | + |
| 6 | +(h/describe "Profile/ collectible list item tests" |
| 7 | + (h/describe "type card" |
| 8 | + (h/test "Renders default and on press fires" |
| 9 | + (let [on-press (h/mock-fn)] |
| 10 | + (h/render-with-theme-provider |
| 11 | + [collectible-list-item/view |
| 12 | + {:type :card |
| 13 | + :on-press on-press}]) |
| 14 | + (h/fire-event :press (h/get-by-label-text :collectible-list-item)) |
| 15 | + (h/was-called on-press))) |
| 16 | + |
| 17 | + (h/test "Renders loading and on press fires" |
| 18 | + (let [on-press (h/mock-fn)] |
| 19 | + (h/render-with-theme-provider |
| 20 | + [collectible-list-item/view |
| 21 | + {:type :card |
| 22 | + :status :loading |
| 23 | + :on-press on-press}]) |
| 24 | + (h/fire-event :press (h/get-by-label-text :collectible-list-item)) |
| 25 | + (h/was-not-called on-press) |
| 26 | + (h/is-truthy (h/get-by-label-text :gradient-overlay)))) |
| 27 | + |
| 28 | + (h/test "Renders counter" |
| 29 | + (h/render-with-theme-provider |
| 30 | + [collectible-list-item/view |
| 31 | + {:type :card |
| 32 | + :counter "x500"}]) |
| 33 | + (h/is-truthy (h/get-by-text "x500"))) |
| 34 | + |
| 35 | + (h/test "Renders counter and collectible name" |
| 36 | + (h/render-with-theme-provider |
| 37 | + [collectible-list-item/view |
| 38 | + {:type :card |
| 39 | + :collectible-name "Doodle #6822" |
| 40 | + :counter "x500"}]) |
| 41 | + (h/is-truthy (h/get-by-text "x500")) |
| 42 | + (h/is-truthy (h/get-by-text "Doodle #6822"))) |
| 43 | + |
| 44 | + (h/test "Renders status cant-fetch" |
| 45 | + (h/render-with-theme-provider |
| 46 | + [collectible-list-item/view |
| 47 | + {:type :card |
| 48 | + :status :cant-fetch}]) |
| 49 | + (h/is-truthy (h/get-by-translation-text :t/cant-fetch-info))) |
| 50 | + |
| 51 | + (h/test "Renders status unsupported" |
| 52 | + (h/render-with-theme-provider |
| 53 | + [collectible-list-item/view |
| 54 | + {:type :card |
| 55 | + :status :unsupported}]) |
| 56 | + (h/is-truthy (h/get-by-translation-text :t/unsupported-file))) |
| 57 | + |
| 58 | + (h/test "Renders status unsupported and counter" |
| 59 | + (h/render-with-theme-provider |
| 60 | + [collectible-list-item/view |
| 61 | + {:type :card |
| 62 | + :status :unsupported |
| 63 | + :counter "x500"}]) |
| 64 | + (h/is-truthy (h/get-by-text "x500")) |
| 65 | + (h/is-truthy (h/get-by-translation-text :t/unsupported-file)))) |
| 66 | + |
| 67 | + (h/describe "type image" |
| 68 | + (h/test "Renders default and on press fires" |
| 69 | + (let [on-press (h/mock-fn)] |
| 70 | + (h/render-with-theme-provider |
| 71 | + [collectible-list-item/view |
| 72 | + {:type :image |
| 73 | + :on-press on-press}]) |
| 74 | + (h/fire-event :press (h/get-by-label-text :collectible-list-item)) |
| 75 | + (h/was-called on-press))) |
| 76 | + |
| 77 | + (h/test "Renders loading and on press fires" |
| 78 | + (let [on-press (h/mock-fn)] |
| 79 | + (h/render-with-theme-provider |
| 80 | + [collectible-list-item/view |
| 81 | + {:type :image |
| 82 | + :status :loading |
| 83 | + :on-press on-press}]) |
| 84 | + (h/fire-event :press (h/get-by-label-text :collectible-list-item)) |
| 85 | + (h/was-not-called on-press) |
| 86 | + (h/is-truthy (h/get-by-label-text :gradient-overlay)))) |
| 87 | + |
| 88 | + (h/test "Renders counter" |
| 89 | + (h/render-with-theme-provider |
| 90 | + [collectible-list-item/view |
| 91 | + {:type :image |
| 92 | + :counter "x500"}]) |
| 93 | + (h/is-truthy (h/get-by-text "x500"))) |
| 94 | + |
| 95 | + (h/test "Renders status cant-fetch" |
| 96 | + (h/render-with-theme-provider |
| 97 | + [collectible-list-item/view |
| 98 | + {:type :image |
| 99 | + :status :cant-fetch}]) |
| 100 | + (h/is-truthy (h/get-by-translation-text :t/cant-fetch-info))) |
| 101 | + |
| 102 | + (h/test "Renders status unsupported" |
| 103 | + (h/render-with-theme-provider |
| 104 | + [collectible-list-item/view |
| 105 | + {:type :image |
| 106 | + :status :unsupported}]) |
| 107 | + (h/is-truthy (h/get-by-translation-text :t/unsupported-file))) |
| 108 | + |
| 109 | + (h/test "Renders status unsupported and counter" |
| 110 | + (h/render-with-theme-provider |
| 111 | + [collectible-list-item/view |
| 112 | + {:type :image |
| 113 | + :status :unsupported |
| 114 | + :counter "x500"}]) |
| 115 | + (h/get-by-text "x500") |
| 116 | + (h/is-truthy (h/get-by-translation-text :t/unsupported-file))))) |
0 commit comments