|
| 1 | +import { graph, lit, sym } from "rdflib"; |
| 2 | +import { GroupQuery } from "./GroupQuery"; |
| 3 | +import { rdf, vcard } from "../namespaces"; |
| 4 | + |
| 5 | +describe(GroupQuery.name, () => { |
| 6 | + describe("query name", () => { |
| 7 | + it("returns nothing if store is empty", () => { |
| 8 | + const store = graph(); |
| 9 | + |
| 10 | + const query = new GroupQuery( |
| 11 | + store, |
| 12 | + sym("https://pod.test/alice/group/1/index.ttl#this"), |
| 13 | + ); |
| 14 | + const result = query.queryName(); |
| 15 | + expect(result).toEqual(""); |
| 16 | + }); |
| 17 | + |
| 18 | + it("returns the group's vcard:fn from the group document", () => { |
| 19 | + const store = graph(); |
| 20 | + store.add( |
| 21 | + sym("https://pod.test/alice/group/1/index.ttl#this"), |
| 22 | + vcard("fn"), |
| 23 | + lit("Family"), |
| 24 | + sym("https://pod.test/alice/group/1/index.ttl"), |
| 25 | + ); |
| 26 | + const query = new GroupQuery( |
| 27 | + store, |
| 28 | + sym("https://pod.test/alice/group/1/index.ttl#this"), |
| 29 | + ); |
| 30 | + const result = query.queryName(); |
| 31 | + expect(result).toEqual("Family"); |
| 32 | + }); |
| 33 | + |
| 34 | + it("returns nothing if vcard:fn is from wrong group", () => { |
| 35 | + const store = graph(); |
| 36 | + store.add( |
| 37 | + sym("https://pod.test/alice/group/1/index.ttl#other"), |
| 38 | + vcard("fn"), |
| 39 | + lit("Family"), |
| 40 | + sym("https://pod.test/alice/group/1/index.ttl"), |
| 41 | + ); |
| 42 | + const query = new GroupQuery( |
| 43 | + store, |
| 44 | + sym("https://pod.test/alice/group/1/index.ttl#this"), |
| 45 | + ); |
| 46 | + const result = query.queryName(); |
| 47 | + expect(result).toEqual(""); |
| 48 | + }); |
| 49 | + |
| 50 | + it("returns nothing, if vcard:fn is missing", () => { |
| 51 | + const store = graph(); |
| 52 | + store.add( |
| 53 | + sym("https://pod.test/alice/group/1/index.ttl#this"), |
| 54 | + rdf("type"), |
| 55 | + vcard("Group"), |
| 56 | + sym("https://pod.test/alice/group/1/index.ttl"), |
| 57 | + ); |
| 58 | + const query = new GroupQuery( |
| 59 | + store, |
| 60 | + sym("https://pod.test/alice/group/1/index.ttl#this"), |
| 61 | + ); |
| 62 | + const result = query.queryName(); |
| 63 | + expect(result).toEqual(""); |
| 64 | + }); |
| 65 | + }); |
| 66 | +}); |
0 commit comments