|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require "rails_helper" |
| 4 | + |
| 5 | +RSpec.describe("RelationType") do |
| 6 | + describe "Constants" do |
| 7 | + it "defines REFERENCE_RELATION_TYPES correctly" do |
| 8 | + expected = ["cites", "is-supplemented-by", "references"] |
| 9 | + |
| 10 | + expect(RelationTypes::REFERENCE_RELATION_TYPES).to(eq(expected)) |
| 11 | + end |
| 12 | + |
| 13 | + it "defines CITATION_RELATION_TYPES correctly" do |
| 14 | + expected = ["is-cited-by", "is-supplement-to", "is-referenced-by"] |
| 15 | + |
| 16 | + expect(RelationTypes::CITATION_RELATION_TYPES).to(eq(expected)) |
| 17 | + end |
| 18 | + |
| 19 | + it "defines INCLUDED_RELATION_TYPES as the union of REFERENCE_RELATION_TYPES and CITATION_RELATION_TYPES" do |
| 20 | + expected = RelationTypes::REFERENCE_RELATION_TYPES | RelationTypes::CITATION_RELATION_TYPES |
| 21 | + |
| 22 | + expect(RelationTypes::INCLUDED_RELATION_TYPES).to(eq(expected)) |
| 23 | + end |
| 24 | + |
| 25 | + it "defines PART_RELATION_TYPES correctly" do |
| 26 | + expected = ["is-part-of", "has-part"] |
| 27 | + |
| 28 | + expect(RelationTypes::PART_RELATION_TYPES).to(eq(expected)) |
| 29 | + end |
| 30 | + |
| 31 | + it "defines NEW_RELATION_TYPES correctly" do |
| 32 | + expected = ["is-reply-to", "is-translation-of", "is-published-in"] |
| 33 | + |
| 34 | + expect(RelationTypes::NEW_RELATION_TYPES).to(eq(expected)) |
| 35 | + end |
| 36 | + |
| 37 | + it "defines RELATIONS_RELATION_TYPES correctly" do |
| 38 | + expected = [ |
| 39 | + "compiles", |
| 40 | + "is-compiled-by", |
| 41 | + "documents", |
| 42 | + "is-documented-by", |
| 43 | + "has-metadata", |
| 44 | + "is-metadata-for", |
| 45 | + "is-derived-from", |
| 46 | + "is-source-of", |
| 47 | + "reviews", |
| 48 | + "is-reviewed-by", |
| 49 | + "requires", |
| 50 | + "is-required-by", |
| 51 | + "continues", |
| 52 | + "is-coutinued-by", |
| 53 | + "has-version", |
| 54 | + "is-version-of", |
| 55 | + "has-part", |
| 56 | + "is-part-of", |
| 57 | + "is-variant-from-of", |
| 58 | + "is-original-form-of", |
| 59 | + "is-identical-to", |
| 60 | + "obsoletes", |
| 61 | + "is-obsolete-by", |
| 62 | + "is-new-version-of", |
| 63 | + "is-previous-version-of", |
| 64 | + "describes", |
| 65 | + "is-described-by", |
| 66 | + ] |
| 67 | + |
| 68 | + expect(RelationTypes::RELATIONS_RELATION_TYPES).to(eq(expected)) |
| 69 | + end |
| 70 | + |
| 71 | + it "defines ALL_RELATION_TYPES as the union of all relation types" do |
| 72 | + expected = ( |
| 73 | + RelationTypes::RELATIONS_RELATION_TYPES | |
| 74 | + RelationTypes::NEW_RELATION_TYPES | |
| 75 | + RelationTypes::CITATION_RELATION_TYPES | |
| 76 | + RelationTypes::REFERENCE_RELATION_TYPES |
| 77 | + ).uniq |
| 78 | + |
| 79 | + expect(RelationTypes::ALL_RELATION_TYPES).to(match_array(expected)) |
| 80 | + end |
| 81 | + |
| 82 | + it "defines OTHER_RELATION_TYPES correctly" do |
| 83 | + expected = ( |
| 84 | + RelationTypes::RELATIONS_RELATION_TYPES | RelationTypes::NEW_RELATION_TYPES |
| 85 | + ) - RelationTypes::INCLUDED_RELATION_TYPES - RelationTypes::PART_RELATION_TYPES |
| 86 | + |
| 87 | + expect(RelationTypes::OTHER_RELATION_TYPES).to(match_array(expected)) |
| 88 | + end |
| 89 | + |
| 90 | + it "defines RELATED_SOURCE_IDS correctly" do |
| 91 | + expected = ["datacite-related", "datacite-crossref", "crossref"] |
| 92 | + |
| 93 | + expect(RelationTypes::RELATED_SOURCE_IDS).to(eq(expected)) |
| 94 | + end |
| 95 | + end |
| 96 | +end |
0 commit comments