From 40e43fd5016993089986b4fd0c5566f99d1e885d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Fri, 26 Apr 2024 12:28:52 +0200 Subject: [PATCH] :recycle: Reorganize tests by level --- .../logic/logic_comp_creation_test.cljc | 45 +++++++++++++++++++ .../types_libraries_test.cljc} | 34 +------------- 2 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 common/test/common_tests/logic/logic_comp_creation_test.cljc rename common/test/common_tests/{types_file_test.cljc => types/types_libraries_test.cljc} (88%) diff --git a/common/test/common_tests/logic/logic_comp_creation_test.cljc b/common/test/common_tests/logic/logic_comp_creation_test.cljc new file mode 100644 index 000000000..577bef06f --- /dev/null +++ b/common/test/common_tests/logic/logic_comp_creation_test.cljc @@ -0,0 +1,45 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + +(ns common-tests.logic.logic-comp-creation-test + (:require + [app.common.files.changes-builder :as pcb] + [app.common.files.libraries-helpers :as cflh] + [clojure.test :as t] + [common-tests.helpers.files :as thf] + [common-tests.helpers.ids-map :as thi])) + +(t/use-fixtures :each thi/test-fixture) + +(t/deftest test-add-component-from-single-shape + (let [; Setup + file (-> (thf/sample-file :file1) + (thf/add-sample-shape :shape1 :type :frame)) + + page (thf/current-page file) + shape1 (thf/get-shape file :shape1) + + ; Action + [_ component-id changes] + (cflh/generate-add-component (pcb/empty-changes) + [shape1] + (:objects page) + (:id page) + (:id file) + true + nil + nil) + + file' (thf/apply-changes file changes) + + ; Get + component (thf/get-component-by-id file' component-id) + root (thf/get-shape-by-id file' (:main-instance-id component))] + + ; Check + (t/is (some? component)) + (t/is (some? root)) + (t/is (= (:component-id root) (:id component))))) diff --git a/common/test/common_tests/types_file_test.cljc b/common/test/common_tests/types/types_libraries_test.cljc similarity index 88% rename from common/test/common_tests/types_file_test.cljc rename to common/test/common_tests/types/types_libraries_test.cljc index 04b76b565..0eab0db07 100644 --- a/common/test/common_tests/types_file_test.cljc +++ b/common/test/common_tests/types/types_libraries_test.cljc @@ -4,11 +4,9 @@ ;; ;; Copyright (c) KALEIDOS INC -(ns common-tests.types-file-test +(ns common-tests.types.types-libraries-test (:require [app.common.data :as d] - [app.common.files.changes-builder :as pcb] - [app.common.files.libraries-helpers :as cflh] [app.common.text :as txt] [app.common.types.colors-list :as ctcl] [app.common.types.component :as ctk] @@ -71,36 +69,6 @@ (t/is (= (:name f1) "Test file")))) -(t/deftest test-add-component-from-single-shape - (let [; Setup - file (-> (thf/sample-file :file1) - (thf/add-sample-shape :shape1 :type :frame)) - - page (thf/current-page file) - shape1 (thf/get-shape file :shape1) - - ; Action - [_ component-id changes] - (cflh/generate-add-component (pcb/empty-changes) - [shape1] - (:objects page) - (:id page) - (:id file) - true - nil - nil) - - file' (thf/apply-changes file changes) - - ; Get - component (thf/get-component-by-id file' component-id) - root (thf/get-shape-by-id file' (:main-instance-id component))] - - ; Check - (t/is (some? component)) - (t/is (some? root)) - (t/is (= (:component-id root) (:id component))))) - (t/deftest test-absorb-components (let [; Setup library (-> (thf/sample-file :library :is-shared true)