Skip to content

Commit 83c4de4

Browse files
committed
contacts: integrate querying group members
1 parent 5117f7c commit 83c4de4

2 files changed

Lines changed: 49 additions & 6 deletions

File tree

contacts/src/rdflib/ContactsModuleRdfLib.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,11 @@ export class ContactsModuleRdfLib implements ContactsModule {
107107
await this.fetchNode(groupNode);
108108
const query = new GroupQuery(this.store, groupNode);
109109
const name = query.queryName();
110+
const members = query.queryMembers();
110111
return {
111112
uri,
112113
name,
113-
members: [
114-
{
115-
name: "Molly Braaten",
116-
uri: "http://localhost:3456/4243dbb6-3126-4bf9-9ea7-45e35c3c8d9d/Person/1973dcec-e71c-476c-87db-0d3332291214/index.ttl#this",
117-
},
118-
],
114+
members,
119115
};
120116
}
121117
}

contacts/src/rdflib/read-group.integration.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,51 @@ describe("read group", () => {
3737
name: "Officials",
3838
});
3939
});
40+
41+
it("returns the group's members", async () => {
42+
const authenticatedFetch = jest.fn();
43+
44+
const store = graph();
45+
const fetcher = new Fetcher(store, {
46+
fetch: authenticatedFetch,
47+
});
48+
const updater = new UpdateManager(store);
49+
const contacts = new ContactsModuleRdfLib({
50+
store,
51+
fetcher,
52+
updater,
53+
});
54+
55+
mockTurtleResponse(
56+
authenticatedFetch,
57+
"https://pod.test/alice/contacts/Group/1/index.ttl",
58+
`
59+
@prefix vcard: <http://www.w3.org/2006/vcard/ns#>.
60+
61+
<#this> a vcard:Group;
62+
vcard:hasMember <./Person/1/index.ttl#this>, <Person/2/index.ttl#this> .
63+
64+
<Person/1/index.ttl#this> vcard:fn "Alice" .
65+
<Person/2/index.ttl#this> vcard:fn "Bob" .
66+
`,
67+
);
68+
69+
const result = await contacts.readGroup(
70+
"https://pod.test/alice/contacts/Group/1/index.ttl#this",
71+
);
72+
73+
expect(result).toMatchObject({
74+
uri: "https://pod.test/alice/contacts/Group/1/index.ttl#this",
75+
members: [
76+
{
77+
uri: "https://pod.test/alice/contacts/Group/1/Person/1/index.ttl#this",
78+
name: "Alice",
79+
},
80+
{
81+
uri: "https://pod.test/alice/contacts/Group/1/Person/2/index.ttl#this",
82+
name: "Bob",
83+
},
84+
],
85+
});
86+
});
4087
});

0 commit comments

Comments
 (0)