mirror of
https://github.com/penpot/penpot.git
synced 2025-03-10 14:51:37 -05:00
♻️ Reorganize tests by level
This commit is contained in:
parent
ff4e27a1d5
commit
40e43fd501
2 changed files with 46 additions and 33 deletions
45
common/test/common_tests/logic/logic_comp_creation_test.cljc
Normal file
45
common/test/common_tests/logic/logic_comp_creation_test.cljc
Normal file
|
@ -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)))))
|
|
@ -4,11 +4,9 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) KALEIDOS INC
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
(ns common-tests.types-file-test
|
(ns common-tests.types.types-libraries-test
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[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.text :as txt]
|
||||||
[app.common.types.colors-list :as ctcl]
|
[app.common.types.colors-list :as ctcl]
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
|
@ -71,36 +69,6 @@
|
||||||
|
|
||||||
(t/is (= (:name f1) "Test file"))))
|
(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
|
(t/deftest test-absorb-components
|
||||||
(let [; Setup
|
(let [; Setup
|
||||||
library (-> (thf/sample-file :library :is-shared true)
|
library (-> (thf/sample-file :library :is-shared true)
|
Loading…
Add table
Reference in a new issue