mirror of
https://github.com/penpot/penpot.git
synced 2026-07-23 22:48:12 +00:00
wip
This commit is contained in:
parent
6db9d2d880
commit
c80a94d9a3
@ -470,6 +470,15 @@
|
||||
[file-data tokens-source]
|
||||
(assoc file-data :tokens-source tokens-source))
|
||||
|
||||
(defn tokens-source?
|
||||
"Returns true if the given id is the current tokens source of the file-data.
|
||||
When no tokens-source is set, the file's own id is considered the source."
|
||||
[file-data id]
|
||||
(assert (uuid? id) "expected valid uuid")
|
||||
(let [source (or (:tokens-source file-data)
|
||||
(:id file-data))]
|
||||
(= source id)))
|
||||
|
||||
(defn get-tokens-lib
|
||||
[file-data]
|
||||
(:tokens-lib file-data))
|
||||
|
||||
@ -283,6 +283,45 @@
|
||||
file-data' (cfo/set-tokens-source file-data source-id)]
|
||||
(t/is (= source-id (:tokens-source file-data'))))))
|
||||
|
||||
(t/deftest test-tokens-source?
|
||||
(t/testing "file-data has no tokens-source, asking for the same id as file-data returns true"
|
||||
(let [file (thf/sample-file :file1)
|
||||
file-data (:data file)]
|
||||
(t/is (true? (cfo/tokens-source? file-data (:id file-data))))))
|
||||
|
||||
(t/testing "file-data has no tokens-source, asking for any other uuid returns false"
|
||||
(let [file (thf/sample-file :file1)
|
||||
file-data (:data file)]
|
||||
(t/is (false? (cfo/tokens-source? file-data (uuid/next))))))
|
||||
|
||||
(t/testing "file-data has tokens-source equal to its own id, asking for the same id as file-data returns true"
|
||||
(let [file (thf/sample-file :file1)
|
||||
file-data (cfo/set-tokens-source (:data file) (:id (:data file)))]
|
||||
(t/is (true? (cfo/tokens-source? file-data (:id file-data))))))
|
||||
|
||||
(t/testing "file-data has tokens-source equal to its own id, asking for any other uuid returns false"
|
||||
(let [file (thf/sample-file :file1)
|
||||
file-data (cfo/set-tokens-source (:data file) (:id (:data file)))]
|
||||
(t/is (false? (cfo/tokens-source? file-data (uuid/next))))))
|
||||
|
||||
(t/testing "file-data has a new uuid as tokens-source, asking for the same id as file-data returns false"
|
||||
(let [source-id (thi/new-id! :tokens-source)
|
||||
file (thf/sample-file :file1)
|
||||
file-data (cfo/set-tokens-source (:data file) source-id)]
|
||||
(t/is (false? (cfo/tokens-source? file-data (:id file-data))))))
|
||||
|
||||
(t/testing "file-data has a new uuid as tokens-source, asking for the same id as the tokens-source returns true"
|
||||
(let [source-id (thi/new-id! :tokens-source)
|
||||
file (thf/sample-file :file1)
|
||||
file-data (cfo/set-tokens-source (:data file) source-id)]
|
||||
(t/is (true? (cfo/tokens-source? file-data source-id)))))
|
||||
|
||||
(t/testing "file-data has a new uuid as tokens-source, asking for any other uuid returns false"
|
||||
(let [source-id (thi/new-id! :tokens-source)
|
||||
file (thf/sample-file :file1)
|
||||
file-data (cfo/set-tokens-source (:data file) source-id)]
|
||||
(t/is (false? (cfo/tokens-source? file-data (uuid/next)))))))
|
||||
|
||||
(t/deftest test-get-tokens-status
|
||||
(t/testing "returns tokens-status from file data"
|
||||
(let [tokens-status (ctos/make-tokens-status)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user