Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
Make sure to use the expected actual form for the tests, add some tests to show behavior
of "identity" operations.
  • Loading branch information
dpetran committed Mar 21, 2023
1 parent a4a1637 commit 010ea42
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions test/fluree/json_ld/impl/context_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,32 @@

(deftest multiple-contexts
(testing "Context map parsing"
(is (= (context/parse [{"schema" "http://schema.org/"},
{"owl" "http://www.w3.org/2002/07/owl#",
"ex" "http://example.org/ns#"}])
{:type-key "@type"
(is (= {:type-key "@type"
"schema" {:id "http://schema.org/"}
"owl" {:id "http://www.w3.org/2002/07/owl#"}
"ex" {:id "http://example.org/ns#"}})))
"ex" {:id "http://example.org/ns#"}}
(context/parse [{"schema" "http://schema.org/"},
{"owl" "http://www.w3.org/2002/07/owl#",
"ex" "http://example.org/ns#"}]))))

(testing "A second context may rely on definitions in the first"
;; this scenario happened with https://w3id.org/security/v1 -> https://w3id.org/security/v2
(is (= (context/parse [{"sec" "https://w3id.org/security#"}
{"EcdsaSecp256k1VerificationKey2019" "sec:EcdsaSecp256k1VerificationKey2019"}])
{:type-key "@type"
(is (= {:type-key "@type"
"sec" {:id "https://w3id.org/security#"},
"EcdsaSecp256k1VerificationKey2019" {:id "https://w3id.org/security#EcdsaSecp256k1VerificationKey2019"}})))
"EcdsaSecp256k1VerificationKey2019" {:id "https://w3id.org/security#EcdsaSecp256k1VerificationKey2019"}}
(context/parse [{"sec" "https://w3id.org/security#"}
{"EcdsaSecp256k1VerificationKey2019" "sec:EcdsaSecp256k1VerificationKey2019"}]))))
(testing "A nil context empties the context"
;; this scenario happened with https://w3id.org/security/v1 -> https://w3id.org/security/v2
(is (= (context/parse [{"sec" "https://w3id.org/security#"}
nil])
{}))))
(let [parsed {:type-key "@type", "sec" {:id "https://w3id.org/security#"}}]
(is (= parsed
(context/parse {"sec" "https://w3id.org/security#"}))
"a parsed context")
(is (= parsed
(context/parse parsed {}))
"an unmodified parsed context")
(is (= {}
(context/parse parsed nil))
"an empty context"))))


(deftest nested-context-details
Expand Down

0 comments on commit 010ea42

Please sign in to comment.