From 6e34ede29973dc8d33f835cff970b67429d5603a Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 8 May 2018 14:24:13 +0300 Subject: [PATCH] reformat test namespaces --- test/cljs/status_im/test/accounts/events.cljs | 32 +- test/cljs/status_im/test/bots/events.cljs | 6 +- test/cljs/status_im/test/chat/models.cljs | 2 +- .../status_im/test/chat/models/message.cljs | 26 +- test/cljs/status_im/test/contacts/events.cljs | 512 +++++++++--------- test/cljs/status_im/test/profile/events.cljs | 1 - test/cljs/status_im/test/protocol/core.cljs | 34 +- .../status_im/test/protocol/web3/inbox.cljs | 1 - test/cljs/status_im/test/runner.cljs | 4 +- test/cljs/status_im/test/utils/clocks.cljs | 2 +- test/cljs/status_im/test/utils/datetime.cljs | 2 +- .../status_im/test/utils/ethereum/eip681.cljs | 3 +- test/cljs/status_im/test/utils/mixpanel.cljs | 7 +- .../test/wallet/transactions/subs.cljs | 1 - 14 files changed, 313 insertions(+), 320 deletions(-) diff --git a/test/cljs/status_im/test/accounts/events.cljs b/test/cljs/status_im/test/accounts/events.cljs index 5aa934c5dd..6eb3f80cf0 100644 --- a/test/cljs/status_im/test/accounts/events.cljs +++ b/test/cljs/status_im/test/accounts/events.cljs @@ -44,9 +44,9 @@ (rf/reg-fx ::account-events/send-keys-update #()) (rf/reg-cofx - ::account-events/get-all-accounts - (fn [coeffects _] - (assoc coeffects :all-accounts [account-from-realm])))) + ::account-events/get-all-accounts + (fn [coeffects _] + (assoc coeffects :all-accounts [account-from-realm])))) #_(deftest accounts-events "load-accounts @@ -56,26 +56,26 @@ (run-test-sync - (test-fixtures) + (test-fixtures) - (rf/dispatch [:initialize-db]) - (rf/dispatch [:set :accounts/current-account-id account-id]) + (rf/dispatch [:initialize-db]) + (rf/dispatch [:set :accounts/current-account-id account-id]) - (let [accounts (rf/subscribe [:get-accounts])] + (let [accounts (rf/subscribe [:get-accounts])] - (testing ":load-accounts event" + (testing ":load-accounts event" ;;Assert the initial state - (is (and (map? @accounts) (empty? @accounts))) + (is (and (map? @accounts) (empty? @accounts))) - (rf/dispatch [:load-accounts]) + (rf/dispatch [:load-accounts]) - (is (= {(:address account-from-realm) account-from-realm} @accounts))) + (is (= {(:address account-from-realm) account-from-realm} @accounts))) - (testing ":add-account event" - (let [new-account' (assoc new-account :network constants/default-network)] + (testing ":add-account event" + (let [new-account' (assoc new-account :network constants/default-network)] - (rf/dispatch [:add-account new-account]) + (rf/dispatch [:add-account new-account]) - (is (= {(:address account-from-realm) account-from-realm - (:address new-account) new-account'} @accounts))))))) + (is (= {(:address account-from-realm) account-from-realm + (:address new-account) new-account'} @accounts))))))) diff --git a/test/cljs/status_im/test/bots/events.cljs b/test/cljs/status_im/test/bots/events.cljs index 5b1534c396..ecce328b96 100644 --- a/test/cljs/status_im/test/bots/events.cljs +++ b/test/cljs/status_im/test/bots/events.cljs @@ -3,7 +3,7 @@ [status-im.bots.events :as bots-events])) (def ^:private initial-db - {:bot-db {} + {:bot-db {} :contacts/contacts {"bot1" {:subscriptions {:feeExplanation @@ -19,7 +19,7 @@ (deftest add-active-bot-subscriptions-test (testing "That active bot subscriptions are correctly transformed and added to db" (let [db (update-in initial-db [:contacts/contacts "bot1" :subscriptions] - bots-events/transform-bot-subscriptions)] + bots-events/transform-bot-subscriptions)] (is (= {[:sliderValue] {:feeExplanation {:fee [:sliderValue] :tx [:transaction]}} [:transaction] {:feeExplanation {:fee [:sliderValue] @@ -41,7 +41,7 @@ (bots-events/set-in-bot-db {:bot "bot1" :path [:sliderValue] :value 2})) - new-db (reduce fake-subscription-call db call-jail-function-n)] + new-db (reduce fake-subscription-call db call-jail-function-n)] (testing "That setting in value in bot-db correctly updates bot-db" (is (= 2 (get-in new-db [:bot-db "bot1" :sliderValue])))) (testing "That subscriptions are fired-off" diff --git a/test/cljs/status_im/test/chat/models.cljs b/test/cljs/status_im/test/chat/models.cljs index cd27d2ded5..bdee998100 100644 --- a/test/cljs/status_im/test/chat/models.cljs +++ b/test/cljs/status_im/test/chat/models.cljs @@ -58,7 +58,7 @@ (testing "it updates it if is-active is passed" (is (get-in (chat/upsert-chat (assoc chat-props :is-active true) cofx) [:db :chats chat-id :is-active]))) (testing "it returns the db unchanged" - (is (= {:db (:db cofx)} (chat/upsert-chat chat-props cofx))))))) + (is (= {:db (:db cofx)} (chat/upsert-chat chat-props cofx))))))) (deftest add-group-chat (let [chat-id "chat-id" diff --git a/test/cljs/status_im/test/chat/models/message.cljs b/test/cljs/status_im/test/chat/models/message.cljs index fe927925e3..52d54be2eb 100644 --- a/test/cljs/status_im/test/chat/models/message.cljs +++ b/test/cljs/status_im/test/chat/models/message.cljs @@ -21,7 +21,7 @@ :from "a" :chat-id "a"})))) (testing "it returns false when it's already in the not-loaded-message-ids" - (is (not (message/add-to-chat? {:db {:chats {"a" {:not-loaded-message-ids #{"message-id" }}}}} + (is (not (message/add-to-chat? {:db {:chats {"a" {:not-loaded-message-ids #{"message-id"}}}}} {:message-id "message-id" :from "a" :chat-id "a"}))))) @@ -41,21 +41,21 @@ (is (= #{"1"} (:message-ids (extract-seen (message/receive message db)))))) (testing "it does not send any when the chat is public" (is (nil? (extract-seen - (message/receive - message - (assoc-in db [:db :chats "chat-id" :public?] true)))))) + (message/receive + message + (assoc-in db [:db :chats "chat-id" :public?] true)))))) (testing "it does not send any when we are in a different chat" (is (nil? (extract-seen - (message/receive - message - (assoc-in db [:db :current-chat-id] :different)))))) + (message/receive + message + (assoc-in db [:db :current-chat-id] :different)))))) (testing "it does not send any when we are not in a chat view" (is (nil? (extract-seen - (message/receive - message - (assoc-in db [:db :view-id] :home)))))) + (message/receive + message + (assoc-in db [:db :view-id] :home)))))) (testing "it does not send any when no public key is in account" (is (nil? (extract-seen - (message/receive - message - (assoc-in db [:db :account/account :public-key] nil)))))))) + (message/receive + message + (assoc-in db [:db :account/account :public-key] nil)))))))) diff --git a/test/cljs/status_im/test/contacts/events.cljs b/test/cljs/status_im/test/contacts/events.cljs index 37cad97bd2..361ce26220 100644 --- a/test/cljs/status_im/test/contacts/events.cljs +++ b/test/cljs/status_im/test/contacts/events.cljs @@ -12,44 +12,44 @@ [status-im.utils.datetime :as datetime])) (def test-contact-group - {:group-id "1501682106404-685e041e-38e7-593e-b42c-fb4cabd7faa4" - :name "Test" + {:group-id "1501682106404-685e041e-38e7-593e-b42c-fb4cabd7faa4" + :name "Test" :timestamp 0 - :order 0 - :pending? false - :contacts (list + :order 0 + :pending? false + :contacts (list {:identity "bchat"} {:identity "Commiteth"} {:identity "demo-bot"})}) (def dapps-contact-group - {:group-id "dapps" - :name "ÐApps" - :order 1 + {:group-id "dapps" + :name "ÐApps" + :order 1 :timestamp 0 - :contacts [{:identity "oaken-water-meter"} - {:identity "melonport"} - {:identity "bchat"} - {:identity "Dentacoin"} - {:identity "Augur"} - {:identity "Ethlance"} - {:identity "Commiteth"}] - :pending? false}) + :contacts [{:identity "oaken-water-meter"} + {:identity "melonport"} + {:identity "bchat"} + {:identity "Dentacoin"} + {:identity "Augur"} + {:identity "Ethlance"} + {:identity "Commiteth"}] + :pending? false}) (def demo-bot-contact - {:address nil - :name "Demo bot" - :description nil - :hide-contact? false - :dapp-hash nil - :photo-path nil - :dapp-url nil - :bot-url "local://demo-bot" + {:address nil + :name "Demo bot" + :description nil + :hide-contact? false + :dapp-hash nil + :photo-path nil + :dapp-url nil + :bot-url "local://demo-bot" :whisper-identity "demo-bot" - :dapp? true - :pending? false - :unremovable? false - :public-key nil}) + :dapp? true + :pending? false + :unremovable? false + :public-key nil}) (def console-contact {:whisper-identity "console" @@ -79,27 +79,27 @@ (rf/reg-fx :data-store/save-chat #()) (rf/reg-cofx - :data-store/get-all-contacts - (fn [coeffects _] - (assoc coeffects :all-contacts []))) + :data-store/get-all-contacts + (fn [coeffects _] + (assoc coeffects :all-contacts []))) (rf/reg-cofx - :data-store/get-local-storage-data - (fn [cofx] - (assoc cofx :get-local-storage-data (constantly nil)))) + :data-store/get-local-storage-data + (fn [cofx] + (assoc cofx :get-local-storage-data (constantly nil)))) (rf/reg-cofx - ::group-events/get-all-contact-groups - (fn [coeffects _] - (assoc coeffects :all-groups {(:group-id test-contact-group) test-contact-group}))) + ::group-events/get-all-contact-groups + (fn [coeffects _] + (assoc coeffects :all-groups {(:group-id test-contact-group) test-contact-group}))) ;;TODO implement tests later for :add-chat? and :bot-url (rf/reg-cofx - ::contacts-events/get-default-contacts-and-groups - (fn [coeffects _] - (assoc coeffects - :default-contacts (select-keys js-res/default-contacts [:demo-bot]) - :default-groups (select-keys js-res/default-contact-groups [:dapps]))))) + ::contacts-events/get-default-contacts-and-groups + (fn [coeffects _] + (assoc coeffects + :default-contacts (select-keys js-res/default-contacts [:demo-bot]) + :default-groups (select-keys js-res/default-contact-groups [:dapps]))))) #_(deftest contacts-events "load-contacts @@ -122,7 +122,7 @@ delete-contact-group" (testing "watch-contact" - (let [contact {:public-key "public-key" + (let [contact {:public-key "public-key" :whisper-identity "whisper-identity"} actual-fx (-> {:db {:web3 "web3"}} (contacts-events/watch-contact contact) @@ -141,16 +141,16 @@ (is (= "public-key" (:public-key actual-fx)))))) (testing "send-contact-request" - (let [contact {:whisper-identity "contact-whisper-identity"} - account {:name "name" - :photo-path "photo-path" - :status "status"} - accounts {"current-account-id" account} - db {:accounts/accounts accounts - :accounts/current-account-id "current-account-id" - :web3 "web3" - :current-public-key "current-public-key" - :notifications {:fcm-token "fcm-token"}} + (let [contact {:whisper-identity "contact-whisper-identity"} + account {:name "name" + :photo-path "photo-path" + :status "status"} + accounts {"current-account-id" account} + db {:accounts/accounts accounts + :accounts/current-account-id "current-account-id" + :web3 "web3" + :current-public-key "current-public-key" + :notifications {:fcm-token "fcm-token"}} actual-fx (-> {:db db} (contacts-events/send-contact-request contact) ::contacts-events/send-contact-request-fx)] @@ -180,274 +180,272 @@ (run-test-sync - (test-fixtures) + (test-fixtures) - (rf/dispatch [:initialize-db]) + (rf/dispatch [:initialize-db]) - (def contacts (rf/subscribe [:get-contacts])) - (def contact-groups (rf/subscribe [:get-contact-groups])) - (def view-id (rf/subscribe [:get :view-id])) + (def contacts (rf/subscribe [:get-contacts])) + (def contact-groups (rf/subscribe [:get-contact-groups])) + (def view-id (rf/subscribe [:get :view-id])) - (testing ":load-contacts event" + (testing ":load-contacts event" - ;;Assert the initial state - (is (and (map? @contacts) (empty? @contacts))) - (rf/dispatch [:load-contacts])) + ;;Assert the initial state + (is (and (map? @contacts) (empty? @contacts))) + (rf/dispatch [:load-contacts])) - (testing ":load-contact-groups event" + (testing ":load-contact-groups event" - ;;Assert the initial state - (is (and (map? @contact-groups) (empty? @contact-groups))) - (rf/dispatch [:load-contact-groups]) - (is (= {(:group-id test-contact-group) test-contact-group} - @contact-groups))) + ;;Assert the initial state + (is (and (map? @contact-groups) (empty? @contact-groups))) + (rf/dispatch [:load-contact-groups]) + (is (= {(:group-id test-contact-group) test-contact-group} + @contact-groups))) - (testing ":load-default-contacts! event" + (testing ":load-default-contacts! event" - ;; :load-default-contacts! event dispatches next 5 events - ;; - ;; :add-contact-groups - ;; :add-contacts - ;; :add-contacts-to-group - ;;TODO :add-chat - ;;TODO :load-commands! - (rf/dispatch [:load-default-contacts!]) + ;; :load-default-contacts! event dispatches next 5 events + ;; + ;; :add-contact-groups + ;; :add-contacts + ;; :add-contacts-to-group + ;;TODO :add-chat + ;;TODO :load-commands! + (rf/dispatch [:load-default-contacts!]) - (rf/dispatch [:set-in [:group/contact-groups "dapps" :timestamp] 0]) + (rf/dispatch [:set-in [:group/contact-groups "dapps" :timestamp] 0]) - (is (= {"dapps" dapps-contact-group - (:group-id test-contact-group) test-contact-group} - @contact-groups)) + (is (= {"dapps" dapps-contact-group + (:group-id test-contact-group) test-contact-group} + @contact-groups)) - (testing "it adds a default contact" - (is (= demo-bot-contact (get @contacts "demo-bot")))) + (testing "it adds a default contact" + (is (= demo-bot-contact (get @contacts "demo-bot")))) - (testing "it adds the console bot" - (is (= console-contact (get @contacts "console")))) + (testing "it adds the console bot" + (is (= console-contact (get @contacts "console")))) - (testing "it does not add any other contact" - (is (= 2 (count (keys @contacts)))))) + (testing "it does not add any other contact" + (is (= 2 (count (keys @contacts)))))) - (def new-contact-public-key "0x048f7d5d4bda298447bbb5b021a34832509bd1a8dbe4e06f9b7223d00a59b6dc14f6e142b21d3220ceb3155a6d8f40ec115cd96394d3cc7c55055b433a1758dc74") - (def new-contact-address "5392ccb49f2e9fef8b8068b3e3b5ba6c020a9aca") - (def new-contact {:name "" - :photo-path "" - :whisper-identity new-contact-public-key - :address new-contact-address - :pending? false}) - (def contact (rf/subscribe [:contact-by-identity new-contact-public-key])) - (def current-chat-id (rf/subscribe [:get-current-chat-id])) + (def new-contact-public-key "0x048f7d5d4bda298447bbb5b021a34832509bd1a8dbe4e06f9b7223d00a59b6dc14f6e142b21d3220ceb3155a6d8f40ec115cd96394d3cc7c55055b433a1758dc74") + (def new-contact-address "5392ccb49f2e9fef8b8068b3e3b5ba6c020a9aca") + (def new-contact {:name "" + :photo-path "" + :whisper-identity new-contact-public-key + :address new-contact-address + :pending? false}) + (def contact (rf/subscribe [:contact-by-identity new-contact-public-key])) + (def current-chat-id (rf/subscribe [:get-current-chat-id])) - (testing ":add-contact-handler event - new contact" + (testing ":add-contact-handler event - new contact" - (rf/dispatch [:set :view-id nil]) - (rf/dispatch [:set :current-chat-id nil]) + (rf/dispatch [:set :view-id nil]) + (rf/dispatch [:set :current-chat-id nil]) - ;; :add-contact-handler event dispatches next 4 events for new contact - ;; - ;; :add-new-contact-and-open-chat - ;; :status-im.contacts.events/add-new-contact - ;; :status-im.contacts.events/send-contact-request - ;;TODO :start-chat + ;; :add-contact-handler event dispatches next 4 events for new contact + ;; + ;; :add-new-contact-and-open-chat + ;; :status-im.contacts.events/add-new-contact + ;; :status-im.contacts.events/send-contact-request + ;;TODO :start-chat - (rf/dispatch [:set :contacts/new-identity new-contact-public-key]) - (rf/dispatch [:add-contact-handler]) + (rf/dispatch [:set :contacts/new-identity new-contact-public-key]) + (rf/dispatch [:add-contact-handler]) - (testing "it returns the new contact from the contact-by-identity sub" - (is (= new-contact (assoc @contact :photo-path "" :name "")))) + (testing "it returns the new contact from the contact-by-identity sub" + (is (= new-contact (assoc @contact :photo-path "" :name "")))) - (testing "it adds the new contact to the list of contacts" - (is (= new-contact - (-> @contacts - (get new-contact-public-key) - (assoc :photo-path "" :name ""))))) + (testing "it adds the new contact to the list of contacts" + (is (= new-contact + (-> @contacts + (get new-contact-public-key) + (assoc :photo-path "" :name ""))))) - (testing "it loads the 1-1 chat" - (is (= :chat @view-id))) + (testing "it loads the 1-1 chat" + (is (= :chat @view-id))) - (testing "it adds the new contact to the chat" - (is (= new-contact-public-key @current-chat-id)))) + (testing "it adds the new contact to the chat" + (is (= new-contact-public-key @current-chat-id)))) - (testing ":contact-request-received event" + (testing ":contact-request-received event" - ;; :contact-request-received event dispatches next 3 events - ;; - ;; :update-contact! - ;; :watch-contact - ;;TODO :update-chat! - (rf/reg-event-db :update-chat! (fn [db _] db)) - (def received-contact {:name "test" - :profile-image "" - :address new-contact-address - :status "test status" - :fcm-token "0xwhatever"}) - (def received-contact1 (merge new-contact - (dissoc received-contact :profile-image) - {:public-key new-contact-public-key})) + ;; :contact-request-received event dispatches next 3 events + ;; + ;; :update-contact! + ;; :watch-contact + ;;TODO :update-chat! + (rf/reg-event-db :update-chat! (fn [db _] db)) + (def received-contact {:name "test" + :profile-image "" + :address new-contact-address + :status "test status" + :fcm-token "0xwhatever"}) + (def received-contact1 (merge new-contact + (dissoc received-contact :profile-image) + {:public-key new-contact-public-key})) - (rf/dispatch [:contact-request-received {:from new-contact-public-key - :payload {:contact received-contact}}]) + (rf/dispatch [:contact-request-received {:from new-contact-public-key + :payload {:contact received-contact}}]) - (testing "it adds the new contact to the list of contacts" - (is (= received-contact1 - (get @contacts new-contact-public-key))))) + (testing "it adds the new contact to the list of contacts" + (is (= received-contact1 + (get @contacts new-contact-public-key))))) - (testing ":contact-update-received event" + (testing ":contact-update-received event" - ;; :contact-update-received event dispatches next 2 events - ;; - ;; :update-contact! - ;;TODO :update-chat! - (let [timestamp (datetime/timestamp)] - (def received-contact2 (assoc received-contact1 - :last-updated timestamp - :status "new status" - :name "new name")) + ;; :contact-update-received event dispatches next 2 events + ;; + ;; :update-contact! + ;;TODO :update-chat! + (let [timestamp (datetime/timestamp)] + (def received-contact2 (assoc received-contact1 + :last-updated timestamp + :status "new status" + :name "new name")) - (rf/dispatch [:contact-update-received {:from new-contact-public-key - :payload {:content {:profile {:profile-image "" - :status "new status" - :name "new name"}} - :timestamp timestamp}}])) + (rf/dispatch [:contact-update-received {:from new-contact-public-key + :payload {:content {:profile {:profile-image "" + :status "new status" + :name "new name"}} + :timestamp timestamp}}])) - (testing "it updates the contact and set the :last-updated key" - (is (= received-contact2 - (get @contacts new-contact-public-key))))) + (testing "it updates the contact and set the :last-updated key" + (is (= received-contact2 + (get @contacts new-contact-public-key))))) - (testing ":hide-contact event" + (testing ":hide-contact event" - ;; :hide-contact event dispatches next 2 events - ;; - ;; :update-contact! - ;;TODO :account-update-keys - (rf/reg-event-db :account-update-keys (fn [db _] db)) + ;; :hide-contact event dispatches next 2 events + ;; + ;; :update-contact! + ;;TODO :account-update-keys + (rf/reg-event-db :account-update-keys (fn [db _] db)) - (rf/dispatch [:hide-contact @contact]) + (rf/dispatch [:hide-contact @contact]) - (testing "it sets the pending? flag to true" - (is (= (assoc received-contact2 :pending? true) - (get @contacts new-contact-public-key))))) + (testing "it sets the pending? flag to true" + (is (= (assoc received-contact2 :pending? true) + (get @contacts new-contact-public-key))))) - (testing ":add-contact-handler event - :add-contact" + (testing ":add-contact-handler event - :add-contact" - ;; :add-contact-handler event dispatches next 4 events - ;; - ;; :add-contact - ;; :status-im.contacts.events/add-new-contact - ;; :status-im.contacts.events/send-contact-request - ;;TODO :discoveries-send-portions - (rf/reg-event-db :discoveries-send-portions (fn [db _] db)) + ;; :add-contact-handler event dispatches next 4 events + ;; + ;; :add-contact + ;; :status-im.contacts.events/add-new-contact + ;; :status-im.contacts.events/send-contact-request + ;;TODO :discoveries-send-portions + (rf/reg-event-db :discoveries-send-portions (fn [db _] db)) - (rf/dispatch [:set :view-id nil]) - (rf/dispatch [:set :current-chat-id nil]) - (rf/dispatch [:set :contacts/new-identity new-contact-public-key]) - (rf/dispatch [:add-contact-handler]) + (rf/dispatch [:set :view-id nil]) + (rf/dispatch [:set :current-chat-id nil]) + (rf/dispatch [:set :contacts/new-identity new-contact-public-key]) + (rf/dispatch [:add-contact-handler]) - (testing "it sets the pending? flag to false" - (is (= (assoc received-contact2 :pending? false) - (get @contacts new-contact-public-key)))) + (testing "it sets the pending? flag to false" + (is (= (assoc received-contact2 :pending? false) + (get @contacts new-contact-public-key)))) - (testing "it loads the 1-1 chat" - (is (= :chat @view-id))) + (testing "it loads the 1-1 chat" + (is (= :chat @view-id))) - (testing "it adds the new contact to the chat" - (is (= new-contact-public-key @current-chat-id)))) + (testing "it adds the new contact to the chat" + (is (= new-contact-public-key @current-chat-id)))) - (testing ":create-new-contact-group event" + (testing ":create-new-contact-group event" - (def new-group-name "new group") - (rf/dispatch [:select-contact new-contact-public-key]) - (rf/dispatch [:select-contact "demo-bot"]) - (rf/dispatch [:select-contact "browse"]) - (rf/dispatch [:deselect-contact "browse"]) + (def new-group-name "new group") + (rf/dispatch [:select-contact new-contact-public-key]) + (rf/dispatch [:select-contact "demo-bot"]) + (rf/dispatch [:select-contact "browse"]) + (rf/dispatch [:deselect-contact "browse"]) - (rf/dispatch [:create-new-contact-group new-group-name]) + (rf/dispatch [:create-new-contact-group new-group-name]) - (rf/dispatch [:deselect-contact "demo-bot"]) - (rf/dispatch [:deselect-contact new-contact-public-key]) - (def new-group-id (->> @contact-groups - (vals) - (filter #(= (:name %) new-group-name)) - (first) - (:group-id))) - (def new-group {:group-id new-group-id - :name new-group-name - :order 2 - :timestamp 0 - :contacts [{:identity new-contact-public-key} + (rf/dispatch [:deselect-contact "demo-bot"]) + (rf/dispatch [:deselect-contact new-contact-public-key]) + (def new-group-id (->> @contact-groups + (vals) + (filter #(= (:name %) new-group-name)) + (first) + (:group-id))) + (def new-group {:group-id new-group-id + :name new-group-name + :order 2 + :timestamp 0 + :contacts [{:identity new-contact-public-key} {:identity "demo-bot"}]}) - (def groups-with-new-group {new-group-id new-group - "dapps" dapps-contact-group - (:group-id test-contact-group) test-contact-group}) - (def groups-with-new-group1 (update groups-with-new-group new-group-id assoc :name "new group name")) - (def groups-with-new-group2 (-> groups-with-new-group1 - (update new-group-id assoc :order 1) - (update "dapps" assoc :order 2))) + (def groups-with-new-group {new-group-id new-group + "dapps" dapps-contact-group + (:group-id test-contact-group) test-contact-group}) + (def groups-with-new-group1 (update groups-with-new-group new-group-id assoc :name "new group name")) + (def groups-with-new-group2 (-> groups-with-new-group1 + (update new-group-id assoc :order 1) + (update "dapps" assoc :order 2))) - (rf/dispatch [:set-in [:group/contact-groups new-group-id :timestamp] 0]) + (rf/dispatch [:set-in [:group/contact-groups new-group-id :timestamp] 0]) - (is (= groups-with-new-group @contact-groups))) + (is (= groups-with-new-group @contact-groups))) - (testing ":set-contact-group-name event" + (testing ":set-contact-group-name event" - (rf/reg-event-db ::prepare-group-name - (fn [db _] (assoc db - :new-chat-name "new group name" - :group/contact-group-id new-group-id))) + (rf/reg-event-db ::prepare-group-name + (fn [db _] (assoc db + :new-chat-name "new group name" + :group/contact-group-id new-group-id))) - (rf/dispatch [::prepare-group-name]) - (rf/dispatch [:set-contact-group-name]) + (rf/dispatch [::prepare-group-name]) + (rf/dispatch [:set-contact-group-name]) - (is (= groups-with-new-group1 @contact-groups))) + (is (= groups-with-new-group1 @contact-groups))) - (testing ":save-contact-group-order event" + (testing ":save-contact-group-order event" - (rf/reg-event-db ::prepare-groups-order - (fn [db _] - (assoc db :group/groups-order - (->> (vals (:group/contact-groups db)) - (remove :pending?) - (sort-by :order >) - (map :group-id))))) + (rf/reg-event-db ::prepare-groups-order + (fn [db _] + (assoc db :group/groups-order + (->> (vals (:group/contact-groups db)) + (remove :pending?) + (sort-by :order >) + (map :group-id))))) - (rf/dispatch [::prepare-groups-order]) - (rf/dispatch [:change-contact-group-order 1 0]) - (rf/dispatch [:save-contact-group-order]) + (rf/dispatch [::prepare-groups-order]) + (rf/dispatch [:change-contact-group-order 1 0]) + (rf/dispatch [:save-contact-group-order]) - (is (= groups-with-new-group2 @contact-groups))) + (is (= groups-with-new-group2 @contact-groups))) - (testing ":add-selected-contacts-to-group event" + (testing ":add-selected-contacts-to-group event" - (rf/dispatch [:select-contact "browse"]) - (rf/dispatch [:add-selected-contacts-to-group]) - (rf/dispatch [:deselect-contact "browse"]) + (rf/dispatch [:select-contact "browse"]) + (rf/dispatch [:add-selected-contacts-to-group]) + (rf/dispatch [:deselect-contact "browse"]) - (is (= (update groups-with-new-group2 new-group-id assoc :contacts [{:identity new-contact-public-key} - {:identity "demo-bot"} - {:identity "browse"}]) - @contact-groups))) + (is (= (update groups-with-new-group2 new-group-id assoc :contacts [{:identity new-contact-public-key} + {:identity "demo-bot"} + {:identity "browse"}]) + @contact-groups))) - (testing ":remove-contact-from-group event" + (testing ":remove-contact-from-group event" - (rf/dispatch [:remove-contact-from-group "browse" new-group-id]) + (rf/dispatch [:remove-contact-from-group "browse" new-group-id]) - (is (= groups-with-new-group2 @contact-groups))) + (is (= groups-with-new-group2 @contact-groups))) + (testing ":add-contacts-to-group event" + (rf/dispatch [:add-contacts-to-group new-group-id ["browse"]]) - (testing ":add-contacts-to-group event" + (is (= (update groups-with-new-group2 new-group-id assoc :contacts [{:identity new-contact-public-key} + {:identity "demo-bot"} + {:identity "browse"}]) + @contact-groups)) - (rf/dispatch [:add-contacts-to-group new-group-id ["browse"]]) + (rf/dispatch [:remove-contact-from-group "browse" new-group-id])) - (is (= (update groups-with-new-group2 new-group-id assoc :contacts [{:identity new-contact-public-key} - {:identity "demo-bot"} - {:identity "browse"}]) - @contact-groups)) + (testing ":delete-contact-group event" - (rf/dispatch [:remove-contact-from-group "browse" new-group-id])) + (rf/dispatch [:delete-contact-group]) - (testing ":delete-contact-group event" - - (rf/dispatch [:delete-contact-group]) - - (is (= (update groups-with-new-group2 new-group-id assoc :pending? true) - @contact-groups))))) + (is (= (update groups-with-new-group2 new-group-id assoc :pending? true) + @contact-groups))))) diff --git a/test/cljs/status_im/test/profile/events.cljs b/test/cljs/status_im/test/profile/events.cljs index accb3e6fec..708dcf1db7 100644 --- a/test/cljs/status_im/test/profile/events.cljs +++ b/test/cljs/status_im/test/profile/events.cljs @@ -17,7 +17,6 @@ :signing-phrase "baby atom limo" :public-key "0x04f5722fba79eb36d73263417531007f43d13af76c6233573a8e3e60f667710611feba0785d751b50609bfc0b7cef35448875c5392c0a91948c95798a0ce600847"}) - (defn test-fixtures [] (rf/reg-fx ::events/init-store #()) (rf/reg-fx ::account-events/save-account #())) diff --git a/test/cljs/status_im/test/protocol/core.cljs b/test/cljs/status_im/test/protocol/core.cljs index ac3e96524c..b1798713d8 100644 --- a/test/cljs/status_im/test/protocol/core.cljs +++ b/test/cljs/status_im/test/protocol/core.cljs @@ -1,5 +1,5 @@ (ns status-im.test.protocol.core - (:require [cljs.test :refer-macros [deftest is testing async ]] + (:require [cljs.test :refer-macros [deftest is testing async]] [cljs.nodejs :as nodejs] re-frame.db status-im.ui.screens.events @@ -29,24 +29,24 @@ (deftest test-send-message! (testing "send contact request & message" (run-test-async - (let [web3 (make-web3) - shh (transport.utils/shh web3) - from (create-keys shh)] - (reset! re-frame.db/app-db {:web3 web3 - :current-public-key from}) + (let [web3 (make-web3) + shh (transport.utils/shh web3) + from (create-keys shh)] + (reset! re-frame.db/app-db {:web3 web3 + :current-public-key from}) - (rf/reg-fx :data-store/save-chat (constantly nil)) - (rf/reg-fx :data-store/save-message (constantly nil)) - (rf/reg-fx :data-store/save-contact (constantly nil)) - (rf/reg-fx :data-store.transport/save (constantly nil)) - (rf/reg-fx :data-store/update-message (constantly nil)) + (rf/reg-fx :data-store/save-chat (constantly nil)) + (rf/reg-fx :data-store/save-message (constantly nil)) + (rf/reg-fx :data-store/save-contact (constantly nil)) + (rf/reg-fx :data-store.transport/save (constantly nil)) + (rf/reg-fx :data-store/update-message (constantly nil)) - (rf/dispatch [:open-chat-with-contact {:whisper-identity contact-whisper-identity}]) - (rf-test/wait-for [::transport.contact/send-new-sym-key] - (rf/dispatch [:set-chat-input-text "test message"]) - (rf/dispatch [:send-current-message]) - (rf-test/wait-for [:update-message-status :protocol/send-status-message-error] - (is true))))))) + (rf/dispatch [:open-chat-with-contact {:whisper-identity contact-whisper-identity}]) + (rf-test/wait-for [::transport.contact/send-new-sym-key] + (rf/dispatch [:set-chat-input-text "test message"]) + (rf/dispatch [:send-current-message]) + (rf-test/wait-for [:update-message-status :protocol/send-status-message-error] + (is true))))))) (deftest test-whisper-version! (testing "Whisper version supported" diff --git a/test/cljs/status_im/test/protocol/web3/inbox.cljs b/test/cljs/status_im/test/protocol/web3/inbox.cljs index ccd7130bd2..9fcc8e5ad9 100644 --- a/test/cljs/status_im/test/protocol/web3/inbox.cljs +++ b/test/cljs/status_im/test/protocol/web3/inbox.cljs @@ -3,7 +3,6 @@ [status-im.transport.utils :as utils] [cljs.test :refer-macros [deftest is testing]])) - (def enode "enode://08d8eb6177b187049f6c97ed3f6c74fbbefb94c7ad10bafcaf4b65ce89c314dcfee0a8bc4e7a5b824dfa08b45b360cc78f34f0aff981f8386caa07652d2e601b@163.172.177.138:40404") (def enode2 "enode://12d8eb6177b187049f6c97ed3f6c74fbbefb94c7ad10bafcaf4b65ce89c314dcfee0a8bc4e7a5b824dfa08b45b360cc78f34f0aff981f8386caa07652d2e601b@163.172.177.138:40404") diff --git a/test/cljs/status_im/test/runner.cljs b/test/cljs/status_im/test/runner.cljs index 3902db185b..39503df898 100644 --- a/test/cljs/status_im/test/runner.cljs +++ b/test/cljs/status_im/test/runner.cljs @@ -19,7 +19,7 @@ [status-im.test.protocol.web3.inbox] [status-im.test.utils.utils] [status-im.test.utils.money] - [status-im.test.utils.clocks] + [status-im.test.utils.clocks] [status-im.test.utils.ethereum.eip681] [status-im.test.utils.ethereum.core] [status-im.test.utils.random] @@ -60,7 +60,7 @@ 'status-im.test.protocol.web3.inbox 'status-im.test.utils.utils 'status-im.test.utils.money - 'status-im.test.utils.clocks + 'status-im.test.utils.clocks 'status-im.test.utils.ethereum.eip681 'status-im.test.utils.ethereum.core 'status-im.test.utils.random diff --git a/test/cljs/status_im/test/utils/clocks.cljs b/test/cljs/status_im/test/utils/clocks.cljs index b712c9313e..7c2f5ba9cf 100644 --- a/test/cljs/status_im/test/utils/clocks.cljs +++ b/test/cljs/status_im/test/utils/clocks.cljs @@ -53,7 +53,7 @@ (str from ": " text ", ")) (defn format-thread [thread] - (apply str (map format-message thread))) + (apply str (map format-message thread))) ;; Invariant we want to maintain. (defn ordered-increasing-text? [thread] diff --git a/test/cljs/status_im/test/utils/datetime.cljs b/test/cljs/status_im/test/utils/datetime.cljs index d9d97544e9..1291808bc6 100644 --- a/test/cljs/status_im/test/utils/datetime.cljs +++ b/test/cljs/status_im/test/utils/datetime.cljs @@ -25,7 +25,7 @@ (with-redefs [t/*ms-fn* (constantly epoch-plus-3d) d/time-fmt (d/mk-fmt "us" d/short-time-format) d/time-zone-offset (t/period :hours 0)] - (is (= (d/to-short-str epoch-plus-3d) "12:00 AM")))) + (is (= (d/to-short-str epoch-plus-3d) "12:00 AM")))) (deftest to-short-str-before-yesterday-us-test (with-redefs [t/*ms-fn* (constantly epoch-plus-3d) diff --git a/test/cljs/status_im/test/utils/ethereum/eip681.cljs b/test/cljs/status_im/test/utils/ethereum/eip681.cljs index edaa13fd71..31e5c6c983 100644 --- a/test/cljs/status_im/test/utils/ethereum/eip681.cljs +++ b/test/cljs/status_im/test/utils/ethereum/eip681.cljs @@ -10,7 +10,7 @@ (is (= nil (eip681/parse-uri "ethereum:"))) (is (= nil (eip681/parse-uri "ethereum:?value=1"))) (is (= nil (eip681/parse-uri "bitcoin:0x1234"))) - (is (= nil(eip681/parse-uri "ethereum:0x1234"))) + (is (= nil (eip681/parse-uri "ethereum:0x1234"))) (is (= {:address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" :chain-id 1} (eip681/parse-uri "ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"))) (is (= {:address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" :value "1" :chain-id 1} (eip681/parse-uri "ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7?value=1"))) (is (= {:address "0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7", :chain-id 1} (eip681/parse-uri "ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7?unknown=1"))) @@ -61,7 +61,6 @@ {:keys [address] :as params} (eip681/parse-uri uri)] (is (= uri (eip681/generate-uri address (dissoc params :address)))))) - (deftest parse-eth-value (is (= nil (eip681/parse-eth-value nil))) (is (= nil (eip681/parse-eth-value 1))) diff --git a/test/cljs/status_im/test/utils/mixpanel.cljs b/test/cljs/status_im/test/utils/mixpanel.cljs index e83b6894b6..9886dadad7 100644 --- a/test/cljs/status_im/test/utils/mixpanel.cljs +++ b/test/cljs/status_im/test/utils/mixpanel.cljs @@ -12,7 +12,6 @@ (true? first-parameter))} {:trigger [:key3 :p1 :p2 :p3]}])) - (deftest matching-event (is (empty? (mixpanel/matching-events {} [:non-existing] definitions))) (is (= 1 (count (mixpanel/matching-events {} [:key] definitions)))) @@ -26,9 +25,9 @@ (deftest drain-events-queue!-test (async done - (let [queue (async/chan (async/sliding-buffer 2000)) - results (atom [])] - (async/go + (let [queue (async/chan (async/sliding-buffer 2000)) + results (atom [])] + (async/go (async/