Skip to content

Commit 300315c

Browse files
committedMar 19, 2025
* more assertions
1 parent 6e927aa commit 300315c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
 

‎src/test/clojure/cljs/externs_parsing_tests.clj

+17-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,27 @@
5252
(testing "JS global console has tag Console"
5353
(let [info (externs/info externs '[console])]
5454
(is (= 'Console (:tag info)))))
55-
(testing "JS global crypto has tag webCrypto.Crypto"
55+
(testing "JS global crypto has tag webCrypto.Crypto from:
56+
@type {!webCrypto.Crypto|undefined}"
5657
(let [info (externs/info externs '[crypto])]
57-
(is (= 'webCrypto.Crypto (:tag info)))))))
58+
(is (= 'webCrypto.Crypto (:tag info)))))
59+
(testing "Generic return type on crypto methods returns ClojureScript relevant
60+
type info:"
61+
(testing "@return {!Promise<!ArrayBuffer>}"
62+
(let [info (externs/info externs '[webCrypto SubtleCrypto prototype encrypt])]
63+
(is (= 'Promise (:ret-tag info)))))
64+
(testing "@return {!Promise<!webCrypto.CryptoKey|!webCrypto.CryptoKeyPair>}"
65+
(let [info (externs/info externs '[webCrypto SubtleCrypto prototype deriveKey])]
66+
(is (= 'Promise (:ret-tag info)))))
67+
(testing "@return {!Int8Array|!Uint8Array|!Uint8ClampedArray|!Int16Array|!Uint16Array|!Int32Array|!Uint32Array|!BigInt64Array|!BigUint64Array}"
68+
(let [info (externs/info externs '[webCrypto SubtleCrypto prototype getRandomValues])]
69+
(is (= 'any (:ret-tag info))))))))
5870

5971
(comment
6072

73+
(let [externs (::ana/externs @(env/default-compiler-env))]
74+
(externs/info externs '[webCrypto Crypto prototype getRandomValues]))
75+
6176
(externs/parse-externs
6277
(externs/resource->source-file (io/resource "goog/object/object.js")))
6378

0 commit comments

Comments
 (0)
Failed to load comments.