solid-logic 1.3.17-615b75c1 → 1.3.17-ec29db42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +1 -1
- package/lib/discovery/discoveryLogic.d.ts +10 -13
- package/lib/discovery/discoveryLogic.d.ts.map +1 -1
- package/lib/discovery/discoveryLogic.js +34 -21
- package/lib/discovery/discoveryLogic.js.map +1 -1
- package/package.json +1 -1
- package/src/discovery/discoveryLogic.ts +60 -83
- package/test/discoveryLogic.test.ts +511 -539
- package/test/helpers/setup.ts +0 -3
|
@@ -2,35 +2,18 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import fetchMock from 'jest-fetch-mock'
|
|
6
|
+
import { Fetcher, Store, sym, UpdateManager } from 'rdflib'
|
|
7
|
+
import * as $rdf from 'rdflib'
|
|
8
|
+
import {
|
|
9
|
+
followOrCreateLink, getAppInstances, getScopedAppInstances, loadCommunityTypeIndexes, loadOrCreateIfNotExists,
|
|
10
|
+
loadPreferences, loadProfile, loadTypeIndexesFor, registerInstanceInTypeIndex, uniqueNodes
|
|
11
|
+
} from '../src/discovery/discoveryLogic'
|
|
12
|
+
import solidNamespace from 'solid-namespace'
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
getAppInstances, getScopedAppInstances, loadTypeIndexesFor, loadPreferences, registerInstanceInTypeIndex,
|
|
12
|
-
uniqueNodes, loadProfile } from '../src/discovery/discoveryLogic.ts'
|
|
14
|
+
/* Discovery Logic tests */
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
/* global $SolidTestEnvironment */
|
|
17
|
-
|
|
18
|
-
/* Discovery Logic tests
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
const ns = {
|
|
22
|
-
dct: Namespace('http://purl.org/dc/terms/'),
|
|
23
|
-
ldp: Namespace('http://www.w3.org/ns/ldp#'),
|
|
24
|
-
meeting: Namespace('http://www.w3.org/ns/pim/meeting#'),
|
|
25
|
-
rdf: Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
|
|
26
|
-
schema: Namespace('http://schema.org/'),
|
|
27
|
-
solid: Namespace('http://www.w3.org/ns/solid/terms#'),
|
|
28
|
-
space: Namespace('http://www.w3.org/ns/pim/space#'),
|
|
29
|
-
stat: Namespace('http://www.w3.org/ns/posix/stat#'),
|
|
30
|
-
vcard: Namespace('http://www.w3.org/2006/vcard/ns#'),
|
|
31
|
-
wf: Namespace('http://www.w3.org/2005/01/wf/flow#'),
|
|
32
|
-
xsd: Namespace('http://www.w3.org/2001/XMLSchema#')
|
|
33
|
-
}
|
|
16
|
+
const ns = solidNamespace($rdf)
|
|
34
17
|
|
|
35
18
|
const prefixes = Object.keys(ns).map(prefix => `@prefix ${prefix}: ${ns[prefix]('')}.\n`).join('') // In turtle
|
|
36
19
|
|
|
@@ -71,8 +54,7 @@ const AliceProfile = `
|
|
|
71
54
|
`
|
|
72
55
|
const AlicePreferences = `
|
|
73
56
|
${Alice} solid:privateTypeIndex ${AlicePrivateTypeIndex};
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
solid:community ${Club} .
|
|
76
58
|
`
|
|
77
59
|
const AlicePublicTypes = `
|
|
78
60
|
|
|
@@ -102,28 +84,28 @@ const AlicePrivateTypes = `
|
|
|
102
84
|
|
|
103
85
|
const AlicePhotos = `
|
|
104
86
|
<>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
87
|
+
a ldp:BasicContainer, ldp:Container;
|
|
88
|
+
dct:modified "2021-04-26T05:34:16Z"^^xsd:dateTime;
|
|
89
|
+
ldp:contains
|
|
90
|
+
<photo1.png>, <photo2.png>, <photo3.png> ;
|
|
91
|
+
stat:mtime 1619415256.541;
|
|
92
|
+
stat:size 4096 .
|
|
111
93
|
`
|
|
112
94
|
|
|
113
95
|
//////////////////////////////////////////////////////////// User Bob
|
|
114
96
|
const BobProfile = `
|
|
115
97
|
<#me> a vcard:Individual;
|
|
116
98
|
|
|
117
|
-
|
|
99
|
+
vcard:fn "Bob" .
|
|
118
100
|
`
|
|
119
101
|
|
|
120
102
|
//////////////////////////////////////////////////////////// User Club
|
|
121
103
|
const ClubProfile = `
|
|
122
104
|
|
|
123
105
|
<#it> a vcard:Organization;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
space:preferencesFile ${ClubPreferencesFile};
|
|
107
|
+
solid:publicTypeIndex ${ClubPublicTypeIndex};
|
|
108
|
+
vcard:fn "Card Club" .
|
|
127
109
|
`
|
|
128
110
|
const ClubPreferences = `
|
|
129
111
|
${Club} solid:privateTypeIndex ${ClubPrivateTypeIndex} .
|
|
@@ -207,534 +189,524 @@ describe("Discovery Logic", () => {
|
|
|
207
189
|
status: 404,
|
|
208
190
|
body: 'Not Found'
|
|
209
191
|
}
|
|
210
|
-
|
|
192
|
+
})
|
|
211
193
|
|
|
212
194
|
|
|
213
195
|
options = { fetch: fetch };
|
|
214
196
|
store = new Store()
|
|
215
197
|
store.fetcher = new Fetcher (store, options);
|
|
216
198
|
store.updater = new UpdateManager(store);
|
|
217
|
-
// util = new UtilityLogic(store, ns, fetcher);
|
|
218
199
|
});
|
|
219
200
|
|
|
220
|
-
// uniqueNodes
|
|
221
|
-
|
|
222
201
|
describe('uniqueNodes', () => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
202
|
+
it('exists', () => {
|
|
203
|
+
expect(uniqueNodes).toBeInstanceOf(Function)
|
|
204
|
+
})
|
|
205
|
+
it('removed duplicates', async () => {
|
|
206
|
+
const input = [ sym('https://a.com/'), sym('https://b.com/'),sym('https://a.com/'), sym('https://a.com/'), sym('https://c.com/'), ]
|
|
207
|
+
const expected = [ sym('https://a.com/'), sym('https://b.com/'), sym('https://c.com/'), ]
|
|
208
|
+
const result = uniqueNodes(input)
|
|
209
|
+
expect(result).toEqual(expected)
|
|
231
210
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
211
|
+
})
|
|
212
|
+
it('handles an empty array', async () => {
|
|
213
|
+
const result = await uniqueNodes([])
|
|
214
|
+
expect(result).toEqual([])
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
describe('loadOrCreateIfNotExists', () => {
|
|
219
|
+
it('exists', () => {
|
|
220
|
+
expect(loadOrCreateIfNotExists).toBeInstanceOf(Function)
|
|
221
|
+
})
|
|
222
|
+
it('does nothing if existing file', async () => {
|
|
223
|
+
const result = await loadOrCreateIfNotExists(store, Alice.doc())
|
|
224
|
+
expect(requests).toEqual([])
|
|
225
|
+
|
|
226
|
+
})
|
|
227
|
+
it('creates empty file if did not exist', async () => {
|
|
228
|
+
const newFile = sym(Bob.doc().uri + '/refhoijhoegg/')
|
|
229
|
+
const result = await loadOrCreateIfNotExists(store, newFile)
|
|
230
|
+
expect(requests[0].method).toEqual('PUT')
|
|
231
|
+
expect(requests[0].url).toEqual(newFile.uri)
|
|
232
|
+
})
|
|
237
233
|
})
|
|
238
|
-
// loadOrCreateIfNotExists
|
|
239
|
-
|
|
240
|
-
describe('loadOrCreateIfNotExists', () => {
|
|
241
|
-
it('exists', () => {
|
|
242
|
-
expect(loadOrCreateIfNotExists).toBeInstanceOf(Function)
|
|
243
|
-
})
|
|
244
|
-
it('does nothing if existing file', async () => {
|
|
245
|
-
const result = await loadOrCreateIfNotExists(store, Alice.doc())
|
|
246
|
-
expect(requests).toEqual([])
|
|
247
|
-
|
|
248
|
-
})
|
|
249
|
-
it('creates empty file if did not exist', async () => {
|
|
250
|
-
const newFile = sym(Bob.doc().uri + /refhoijhoegg/)
|
|
251
|
-
const result = await loadOrCreateIfNotExists(store, newFile)
|
|
252
|
-
expect(requests[0].method).toEqual('PUT')
|
|
253
|
-
expect(requests[0].url).toEqual(newFile.uri)
|
|
254
|
-
})
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
// followOrCreateLink
|
|
258
|
-
|
|
259
|
-
describe('followOrCreateLink', () => {
|
|
260
|
-
it('exists', () => {
|
|
261
|
-
expect(followOrCreateLink).toBeInstanceOf(Function)
|
|
262
|
-
})
|
|
263
|
-
it('follows existing link', async () => {
|
|
264
|
-
const result = await followOrCreateLink(store, Alice, ns.space('preferencesFile'), 'blah', Alice.doc())
|
|
265
|
-
expect(result).toEqual(AlicePreferencesFile)
|
|
266
|
-
|
|
267
|
-
})
|
|
268
|
-
it('creates empty file if did not exist and new link', async () => {
|
|
269
|
-
const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
|
|
270
|
-
const newFile = sym(suggestion)
|
|
271
|
-
const result = await followOrCreateLink(store, Bob, ns.space('preferencesFile'), sym(suggestion), Bob.doc())
|
|
272
|
-
expect(result).toEqual(sym(suggestion))
|
|
273
|
-
expect(requests[0].method).toEqual('PATCH') // or patch first?
|
|
274
|
-
expect(requests[0].url).toEqual(Bob.doc().uri)
|
|
275
|
-
expect(requests[1].method).toEqual('PUT') // or patch first?
|
|
276
|
-
expect(requests[1].url).toEqual(suggestion)
|
|
277
|
-
expect(store.holds(Bob, ns.space('preferencesFile'), sym(suggestion), Bob.doc())).toEqual(true)
|
|
278
|
-
})
|
|
279
|
-
//
|
|
280
|
-
it('returns null if it cannot create the new file', async () => {
|
|
281
|
-
const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
|
|
282
|
-
const newFile = sym(suggestion)
|
|
283
|
-
statustoBeReturned = 403 // Unauthorized
|
|
284
|
-
const result = await followOrCreateLink(store, Bob, ns.space('preferencesFile'), sym(suggestion), Bob.doc())
|
|
285
|
-
expect(result).toEqual(null)
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
describe('loadProfile', () => {
|
|
291
|
-
it('exists', () => {
|
|
292
|
-
expect(loadProfile).toBeInstanceOf(Function)
|
|
293
|
-
})
|
|
294
|
-
it('loads data', async () => {
|
|
295
|
-
const result = await loadProfile(store, user)
|
|
296
|
-
expect(result).toBeInstanceOf(Object)
|
|
297
|
-
expect(result.uri).toEqual(AliceProfileFile.uri)
|
|
298
|
-
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
299
|
-
expect(store.holds(user, ns.space('preferencesFile'), AlicePreferencesFile, profile)).toEqual(true)
|
|
300
|
-
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
301
|
-
})
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
describe('loadPreferences', () => {
|
|
305
|
-
it('exists', () => {
|
|
306
|
-
expect(loadPreferences).toBeInstanceOf(Function)
|
|
307
|
-
})
|
|
308
|
-
it('loads data', async () => {
|
|
309
|
-
const result = await loadPreferences(store, Alice)
|
|
310
|
-
expect(result).toBeInstanceOf(Object)
|
|
311
|
-
expect(result.uri).toEqual(AlicePreferencesFile.uri)
|
|
312
|
-
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
313
|
-
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
314
|
-
|
|
315
|
-
expect(store.statementsMatching(null, null, null, AlicePreferencesFile).length).toEqual(2)
|
|
316
|
-
expect(store.holds(user, ns.solid('privateTypeIndex'), AlicePrivateTypeIndex, AlicePreferencesFile)).toEqual(true)
|
|
317
|
-
})
|
|
318
|
-
it('creates new file', async () => {
|
|
319
|
-
const result = await loadPreferences(store, Bob)
|
|
320
|
-
|
|
321
|
-
const patchRequest = requests[0]
|
|
322
|
-
expect(patchRequest.method).toEqual('PATCH')
|
|
323
|
-
expect(patchRequest.url).toEqual(Bob.doc().uri)
|
|
324
|
-
const text = await patchRequest.text()
|
|
325
|
-
expect(text).toContain('INSERT DATA { <https://bob.example.com/profile/card.ttl#me> <http://www.w3.org/ns/pim/space#preferencesFile> <https://bob.example.com/Settings/Preferences.ttl> .')
|
|
326
|
-
|
|
327
|
-
const putRequest = requests[1]
|
|
328
|
-
expect(putRequest.method).toEqual('PUT')
|
|
329
|
-
expect(putRequest.url).toEqual('https://bob.example.com/Settings/Preferences.ttl')
|
|
330
|
-
// const text2 = await putRequest.text()
|
|
331
|
-
expect(web[putRequest.url]).toEqual('')
|
|
332
|
-
|
|
333
|
-
})
|
|
334
234
|
|
|
235
|
+
describe('followOrCreateLink', () => {
|
|
236
|
+
it('exists', () => {
|
|
237
|
+
expect(followOrCreateLink).toBeInstanceOf(Function)
|
|
335
238
|
})
|
|
239
|
+
it('follows existing link', async () => {
|
|
240
|
+
const suggestion = 'https://alice.example.com/settings/prefsSuggestion.ttl'
|
|
241
|
+
const result = await followOrCreateLink(store, Alice, ns.space('preferencesFile'), sym(suggestion), Alice.doc())
|
|
242
|
+
expect(result).toEqual(AlicePreferencesFile)
|
|
336
243
|
|
|
337
|
-
const AliceScopes = [ {
|
|
338
|
-
"agent": {
|
|
339
|
-
"classOrder": 5,
|
|
340
|
-
"termType": "NamedNode",
|
|
341
|
-
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
342
|
-
},
|
|
343
|
-
"index": {
|
|
344
|
-
"classOrder": 5,
|
|
345
|
-
"termType": "NamedNode",
|
|
346
|
-
"value": "https://alice.example.com/profle/public-type-index.ttl",
|
|
347
|
-
},
|
|
348
|
-
"label": "public",
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
"agent": {
|
|
352
|
-
"classOrder": 5,
|
|
353
|
-
"termType": "NamedNode",
|
|
354
|
-
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
355
|
-
},
|
|
356
|
-
"index": {
|
|
357
|
-
"classOrder": 5,
|
|
358
|
-
"termType": "NamedNode",
|
|
359
|
-
"value": "https://alice.example.com/settings/private-type-index.ttl",
|
|
360
|
-
},
|
|
361
|
-
"label": "private",
|
|
362
|
-
}
|
|
363
|
-
];
|
|
364
|
-
|
|
365
|
-
describe('loadTypeIndexesFor', () => {
|
|
366
|
-
it('exists', () => {
|
|
367
|
-
expect(loadTypeIndexesFor).toBeInstanceOf(Function)
|
|
368
|
-
})
|
|
369
|
-
it('loads data', async () => {
|
|
370
|
-
const result = await loadTypeIndexesFor(store, user)
|
|
371
|
-
expect(result).toEqual(AliceScopes)
|
|
372
|
-
expect(store.statementsMatching(null, null, null, AlicePrivateTypeIndex).length).toEqual(
|
|
373
|
-
|
|
374
|
-
8)
|
|
375
|
-
expect(store.statementsMatching(null, null, null, AlicePublicTypeIndex).length).toEqual(8)
|
|
376
|
-
})
|
|
377
244
|
})
|
|
245
|
+
it('creates empty file if did not exist and new link', async () => {
|
|
246
|
+
const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
|
|
247
|
+
const result = await followOrCreateLink(store, Bob, ns.space('preferencesFile'), sym(suggestion), Bob.doc())
|
|
248
|
+
expect(result).toEqual(sym(suggestion))
|
|
249
|
+
expect(requests[0].method).toEqual('PATCH') // or patch first?
|
|
250
|
+
expect(requests[0].url).toEqual(Bob.doc().uri)
|
|
251
|
+
expect(requests[1].method).toEqual('PUT') // or patch first?
|
|
252
|
+
expect(requests[1].url).toEqual(suggestion)
|
|
253
|
+
expect(store.holds(Bob, ns.space('preferencesFile'), sym(suggestion), Bob.doc())).toEqual(true)
|
|
254
|
+
})
|
|
255
|
+
//
|
|
256
|
+
it('returns null if it cannot create the new file', async () => {
|
|
257
|
+
const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
|
|
258
|
+
statustoBeReturned = 403 // Unauthorized
|
|
259
|
+
const result = await followOrCreateLink(store, Bob, ns.space('preferencesFile'), sym(suggestion), Bob.doc())
|
|
260
|
+
expect(result).toEqual(null)
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
describe('loadProfile', () => {
|
|
266
|
+
it('exists', () => {
|
|
267
|
+
expect(loadProfile).toBeInstanceOf(Function)
|
|
268
|
+
})
|
|
269
|
+
it('loads data', async () => {
|
|
270
|
+
const result = await loadProfile(store, user)
|
|
271
|
+
expect(result).toBeInstanceOf(Object)
|
|
272
|
+
expect(result.uri).toEqual(AliceProfileFile.uri)
|
|
273
|
+
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
274
|
+
expect(store.holds(user, ns.space('preferencesFile'), AlicePreferencesFile, profile)).toEqual(true)
|
|
275
|
+
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
describe('loadPreferences', () => {
|
|
280
|
+
it('exists', () => {
|
|
281
|
+
expect(loadPreferences).toBeInstanceOf(Function)
|
|
282
|
+
})
|
|
283
|
+
it('loads data', async () => {
|
|
284
|
+
const result = await loadPreferences(store, Alice)
|
|
285
|
+
expect(result).toBeInstanceOf(Object)
|
|
286
|
+
expect(result.uri).toEqual(AlicePreferencesFile.uri)
|
|
287
|
+
expect(store.holds(user, ns.rdf('type'), ns.vcard('Individual'), profile)).toEqual(true)
|
|
288
|
+
expect(store.statementsMatching(null, null, null, profile).length).toEqual(4)
|
|
289
|
+
|
|
290
|
+
expect(store.statementsMatching(null, null, null, AlicePreferencesFile).length).toEqual(2)
|
|
291
|
+
expect(store.holds(user, ns.solid('privateTypeIndex'), AlicePrivateTypeIndex, AlicePreferencesFile)).toEqual(true)
|
|
292
|
+
})
|
|
293
|
+
it('creates new file', async () => {
|
|
294
|
+
const result = await loadPreferences(store, Bob)
|
|
295
|
+
|
|
296
|
+
const patchRequest = requests[0]
|
|
297
|
+
expect(patchRequest.method).toEqual('PATCH')
|
|
298
|
+
expect(patchRequest.url).toEqual(Bob.doc().uri)
|
|
299
|
+
const text = await patchRequest.text()
|
|
300
|
+
expect(text).toContain('INSERT DATA { <https://bob.example.com/profile/card.ttl#me> <http://www.w3.org/ns/pim/space#preferencesFile> <https://bob.example.com/Settings/Preferences.ttl> .')
|
|
301
|
+
|
|
302
|
+
const putRequest = requests[1]
|
|
303
|
+
expect(putRequest.method).toEqual('PUT')
|
|
304
|
+
expect(putRequest.url).toEqual('https://bob.example.com/Settings/Preferences.ttl')
|
|
305
|
+
expect(web[putRequest.url]).toEqual('')
|
|
306
|
+
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
const AliceScopes = [ {
|
|
312
|
+
"agent": {
|
|
313
|
+
"classOrder": 5,
|
|
314
|
+
"termType": "NamedNode",
|
|
315
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
316
|
+
},
|
|
317
|
+
"index": {
|
|
318
|
+
"classOrder": 5,
|
|
319
|
+
"termType": "NamedNode",
|
|
320
|
+
"value": "https://alice.example.com/profle/public-type-index.ttl",
|
|
321
|
+
},
|
|
322
|
+
"label": "public",
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"agent": {
|
|
326
|
+
"classOrder": 5,
|
|
327
|
+
"termType": "NamedNode",
|
|
328
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
329
|
+
},
|
|
330
|
+
"index": {
|
|
331
|
+
"classOrder": 5,
|
|
332
|
+
"termType": "NamedNode",
|
|
333
|
+
"value": "https://alice.example.com/settings/private-type-index.ttl",
|
|
334
|
+
},
|
|
335
|
+
"label": "private",
|
|
336
|
+
}
|
|
337
|
+
];
|
|
338
|
+
|
|
339
|
+
describe('loadTypeIndexesFor', () => {
|
|
340
|
+
it('exists', () => {
|
|
341
|
+
expect(loadTypeIndexesFor).toBeInstanceOf(Function)
|
|
342
|
+
})
|
|
343
|
+
it('loads data', async () => {
|
|
344
|
+
const result = await loadTypeIndexesFor(store, user)
|
|
345
|
+
expect(result).toEqual(AliceScopes)
|
|
346
|
+
expect(store.statementsMatching(null, null, null, AlicePrivateTypeIndex).length).toEqual(8)
|
|
347
|
+
expect(store.statementsMatching(null, null, null, AlicePublicTypeIndex).length).toEqual(8)
|
|
348
|
+
})
|
|
349
|
+
})
|
|
378
350
|
|
|
379
351
|
const ClubScopes =
|
|
380
352
|
[
|
|
353
|
+
{
|
|
354
|
+
"agent": {
|
|
355
|
+
"classOrder": 5,
|
|
356
|
+
"termType": "NamedNode",
|
|
357
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
358
|
+
},
|
|
359
|
+
"index": {
|
|
360
|
+
"classOrder": 5,
|
|
361
|
+
"termType": "NamedNode",
|
|
362
|
+
"value": "https://club.example.com/profle/public-type-index.ttl",
|
|
363
|
+
},
|
|
364
|
+
"label": "public",
|
|
365
|
+
},
|
|
381
366
|
{
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
},
|
|
387
|
-
"index": {
|
|
388
|
-
"classOrder": 5,
|
|
389
|
-
"termType": "NamedNode",
|
|
390
|
-
"value": "https://club.example.com/profle/public-type-index.ttl",
|
|
391
|
-
},
|
|
392
|
-
"label": "public",
|
|
367
|
+
"agent": {
|
|
368
|
+
"classOrder": 5,
|
|
369
|
+
"termType": "NamedNode",
|
|
370
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
393
371
|
},
|
|
394
|
-
|
|
395
|
-
"
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
"value": "https://club.example.com/profile/card.ttl#it",
|
|
399
|
-
},
|
|
400
|
-
"index": {
|
|
401
|
-
"classOrder": 5,
|
|
402
|
-
"termType": "NamedNode",
|
|
403
|
-
"value": "https://club.example.com/settings/private-type-index.ttl",
|
|
404
|
-
},
|
|
405
|
-
"label": "private",
|
|
372
|
+
"index": {
|
|
373
|
+
"classOrder": 5,
|
|
374
|
+
"termType": "NamedNode",
|
|
375
|
+
"value": "https://club.example.com/settings/private-type-index.ttl",
|
|
406
376
|
},
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
377
|
+
"label": "private",
|
|
378
|
+
},
|
|
379
|
+
];
|
|
380
|
+
describe('loadCommunityTypeIndexes', () => {
|
|
381
|
+
it('exists', () => {
|
|
382
|
+
expect(loadCommunityTypeIndexes).toBeInstanceOf(Function)
|
|
383
|
+
})
|
|
384
|
+
it('loads data', async () => {
|
|
385
|
+
const result = await loadCommunityTypeIndexes(store, user) // @@ tbd
|
|
386
|
+
expect(result).toEqual(ClubScopes)
|
|
387
|
+
})
|
|
388
|
+
})
|
|
417
389
|
|
|
418
390
|
const AliceAndClubScopes =
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
})
|
|
391
|
+
[
|
|
392
|
+
{
|
|
393
|
+
"instance": {
|
|
394
|
+
"classOrder": 5,
|
|
395
|
+
"termType": "NamedNode",
|
|
396
|
+
"value": "https://alice.example.com/publicStuff/actionItems.ttl#this",
|
|
397
|
+
},
|
|
398
|
+
"scope": {
|
|
399
|
+
"agent": {
|
|
400
|
+
"classOrder": 5,
|
|
401
|
+
"termType": "NamedNode",
|
|
402
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
403
|
+
},
|
|
404
|
+
"index": {
|
|
405
|
+
"classOrder": 5,
|
|
406
|
+
"termType": "NamedNode",
|
|
407
|
+
"value": "https://alice.example.com/profle/public-type-index.ttl",
|
|
408
|
+
},
|
|
409
|
+
"label": "public",
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"instance": {
|
|
414
|
+
"classOrder": 5,
|
|
415
|
+
"termType": "NamedNode",
|
|
416
|
+
"value": "https://alice.example.com/project4/issues.ttl#this",
|
|
417
|
+
},
|
|
418
|
+
"scope": {
|
|
419
|
+
"agent": {
|
|
420
|
+
"classOrder": 5,
|
|
421
|
+
"termType": "NamedNode",
|
|
422
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
423
|
+
},
|
|
424
|
+
"index": {
|
|
425
|
+
"classOrder": 5,
|
|
426
|
+
"termType": "NamedNode",
|
|
427
|
+
"value": "https://alice.example.com/profle/public-type-index.ttl",
|
|
428
|
+
},
|
|
429
|
+
"label": "public",
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"instance": {
|
|
434
|
+
"classOrder": 5,
|
|
435
|
+
"termType": "NamedNode",
|
|
436
|
+
"value": "https://alice.example.com/privateStuff/ToDo.ttl#this",
|
|
437
|
+
},
|
|
438
|
+
"scope": {
|
|
439
|
+
"agent": {
|
|
440
|
+
"classOrder": 5,
|
|
441
|
+
"termType": "NamedNode",
|
|
442
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
443
|
+
},
|
|
444
|
+
"index": {
|
|
445
|
+
"classOrder": 5,
|
|
446
|
+
"termType": "NamedNode",
|
|
447
|
+
"value": "https://alice.example.com/settings/private-type-index.ttl",
|
|
448
|
+
},
|
|
449
|
+
"label": "private",
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"instance": {
|
|
454
|
+
"classOrder": 5,
|
|
455
|
+
"termType": "NamedNode",
|
|
456
|
+
"value": "https://alice.example.com/privateStuff/Goals.ttl#this",
|
|
457
|
+
},
|
|
458
|
+
"scope": {
|
|
459
|
+
"agent": {
|
|
460
|
+
"classOrder": 5,
|
|
461
|
+
"termType": "NamedNode",
|
|
462
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
463
|
+
},
|
|
464
|
+
"index": {
|
|
465
|
+
"classOrder": 5,
|
|
466
|
+
"termType": "NamedNode",
|
|
467
|
+
"value": "https://alice.example.com/settings/private-type-index.ttl",
|
|
468
|
+
},
|
|
469
|
+
"label": "private",
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"instance": {
|
|
474
|
+
"classOrder": 5,
|
|
475
|
+
"termType": "NamedNode",
|
|
476
|
+
"value": "https://alice.example.com/privateStuff/workingOn.ttl#this",
|
|
477
|
+
},
|
|
478
|
+
"scope": {
|
|
479
|
+
"agent": {
|
|
480
|
+
"classOrder": 5,
|
|
481
|
+
"termType": "NamedNode",
|
|
482
|
+
"value": "https://alice.example.com/profile/card.ttl#me",
|
|
483
|
+
},
|
|
484
|
+
"index": {
|
|
485
|
+
"classOrder": 5,
|
|
486
|
+
"termType": "NamedNode",
|
|
487
|
+
"value": "https://alice.example.com/settings/private-type-index.ttl",
|
|
488
|
+
},
|
|
489
|
+
"label": "private",
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"instance": {
|
|
494
|
+
"classOrder": 5,
|
|
495
|
+
"termType": "NamedNode",
|
|
496
|
+
"value": "https://club.example.com/publicStuff/actionItems.ttl#this",
|
|
497
|
+
},
|
|
498
|
+
"scope": {
|
|
499
|
+
"agent": {
|
|
500
|
+
"classOrder": 5,
|
|
501
|
+
"termType": "NamedNode",
|
|
502
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
503
|
+
},
|
|
504
|
+
"index": {
|
|
505
|
+
"classOrder": 5,
|
|
506
|
+
"termType": "NamedNode",
|
|
507
|
+
"value": "https://club.example.com/profle/public-type-index.ttl",
|
|
508
|
+
},
|
|
509
|
+
"label": "public",
|
|
510
|
+
},
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"instance": {
|
|
514
|
+
"classOrder": 5,
|
|
515
|
+
"termType": "NamedNode",
|
|
516
|
+
"value": "https://club.example.com/project4/clubIssues.ttl#this",
|
|
517
|
+
},
|
|
518
|
+
"scope": {
|
|
519
|
+
"agent": {
|
|
520
|
+
"classOrder": 5,
|
|
521
|
+
"termType": "NamedNode",
|
|
522
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
523
|
+
},
|
|
524
|
+
"index": {
|
|
525
|
+
"classOrder": 5,
|
|
526
|
+
"termType": "NamedNode",
|
|
527
|
+
"value": "https://club.example.com/profle/public-type-index.ttl",
|
|
528
|
+
},
|
|
529
|
+
"label": "public",
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"instance": {
|
|
534
|
+
"classOrder": 5,
|
|
535
|
+
"termType": "NamedNode",
|
|
536
|
+
"value": "https://club.example.com/privateStuff/ToDo.ttl#this",
|
|
537
|
+
},
|
|
538
|
+
"scope": {
|
|
539
|
+
"agent": {
|
|
540
|
+
"classOrder": 5,
|
|
541
|
+
"termType": "NamedNode",
|
|
542
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
543
|
+
},
|
|
544
|
+
"index": {
|
|
545
|
+
"classOrder": 5,
|
|
546
|
+
"termType": "NamedNode",
|
|
547
|
+
"value": "https://club.example.com/settings/private-type-index.ttl",
|
|
548
|
+
},
|
|
549
|
+
"label": "private",
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
"instance": {
|
|
554
|
+
"classOrder": 5,
|
|
555
|
+
"termType": "NamedNode",
|
|
556
|
+
"value": "https://club.example.com/privateStuff/Goals.ttl#this",
|
|
557
|
+
},
|
|
558
|
+
"scope": {
|
|
559
|
+
"agent": {
|
|
560
|
+
"classOrder": 5,
|
|
561
|
+
"termType": "NamedNode",
|
|
562
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
563
|
+
},
|
|
564
|
+
"index": {
|
|
565
|
+
"classOrder": 5,
|
|
566
|
+
"termType": "NamedNode",
|
|
567
|
+
"value": "https://club.example.com/settings/private-type-index.ttl",
|
|
568
|
+
},
|
|
569
|
+
"label": "private",
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
"instance": {
|
|
574
|
+
"classOrder": 5,
|
|
575
|
+
"termType": "NamedNode",
|
|
576
|
+
"value": "https://club.example.com/privateStuff/tasks.ttl#this",
|
|
577
|
+
},
|
|
578
|
+
"scope": {
|
|
579
|
+
"agent": {
|
|
580
|
+
"classOrder": 5,
|
|
581
|
+
"termType": "NamedNode",
|
|
582
|
+
"value": "https://club.example.com/profile/card.ttl#it",
|
|
583
|
+
},
|
|
584
|
+
"index": {
|
|
585
|
+
"classOrder": 5,
|
|
586
|
+
"termType": "NamedNode",
|
|
587
|
+
"value": "https://club.example.com/settings/private-type-index.ttl",
|
|
588
|
+
},
|
|
589
|
+
"label": "private",
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
]
|
|
593
|
+
|
|
594
|
+
describe('getScopedAppInstances', () => {
|
|
595
|
+
it('exists', () => {
|
|
596
|
+
expect(getScopedAppInstances).toBeInstanceOf(Function)
|
|
597
|
+
})
|
|
598
|
+
it('pulls in users scopes and also community ones', async () => {
|
|
599
|
+
const result = await getScopedAppInstances(store, Tracker, user)
|
|
600
|
+
expect(result).toEqual(AliceAndClubScopes)
|
|
601
|
+
})
|
|
602
|
+
it('creates new typeIndeex files where they dont exist', async () => {
|
|
603
|
+
const result = await getScopedAppInstances(store, Tracker, Bob)
|
|
604
|
+
|
|
605
|
+
expect(requests[0].method).toEqual('PATCH') // Add link to preferrencesFile
|
|
606
|
+
expect(requests[0].url).toEqual('https://bob.example.com/profile/card.ttl')
|
|
607
|
+
|
|
608
|
+
expect(requests[1].method).toEqual('PUT') // Link to pub typ ind
|
|
609
|
+
expect(requests[1].url).toEqual('https://bob.example.com/profile/publicTypeIndex.ttl')
|
|
610
|
+
|
|
611
|
+
expect(requests[2].method).toEqual('PATCH') // Add link to preferrencesFile
|
|
612
|
+
expect(requests[2].url).toEqual('https://bob.example.com/profile/card.ttl')
|
|
613
|
+
|
|
614
|
+
expect(requests[3].method).toEqual('PATCH')
|
|
615
|
+
expect(requests[3].url).toEqual('https://bob.example.com/Settings/Preferences.ttl')
|
|
616
|
+
|
|
617
|
+
expect(requests[4].method).toEqual('PUT')
|
|
618
|
+
expect(requests[4].url).toEqual('https://bob.example.com/Settings/privateTypeIndex.ttl')
|
|
619
|
+
|
|
620
|
+
expect(requests.length).toEqual(5)
|
|
621
|
+
|
|
651
622
|
})
|
|
623
|
+
})
|
|
652
624
|
|
|
653
625
|
const TRACKERS =
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
})
|
|
711
|
-
it('finds trackers', async () => {
|
|
712
|
-
const result = await getAppInstances(store, Tracker)
|
|
713
|
-
expect(result).toEqual(TRACKERS)
|
|
714
|
-
expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
|
|
715
|
-
})
|
|
716
|
-
it('finds images in containers', async () => {
|
|
717
|
-
const result = await getAppInstances(store, Image)
|
|
718
|
-
expect(result.length).toEqual(3)
|
|
719
|
-
expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
|
|
720
|
-
expect(result.map(x => x.uri).join()).toEqual("https://alice.example.com/profile/Photos/photo1.png,https://alice.example.com/profile/Photos/photo2.png,https://alice.example.com/profile/Photos/photo3.png")
|
|
721
|
-
})
|
|
626
|
+
[
|
|
627
|
+
{
|
|
628
|
+
"classOrder": 5,
|
|
629
|
+
"termType": "NamedNode",
|
|
630
|
+
"value": "https://alice.example.com/publicStuff/actionItems.ttl#this",
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"classOrder": 5,
|
|
634
|
+
"termType": "NamedNode",
|
|
635
|
+
"value": "https://alice.example.com/project4/issues.ttl#this",
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
"classOrder": 5,
|
|
639
|
+
"termType": "NamedNode",
|
|
640
|
+
"value": "https://alice.example.com/privateStuff/ToDo.ttl#this",
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"classOrder": 5,
|
|
644
|
+
"termType": "NamedNode",
|
|
645
|
+
"value": "https://alice.example.com/privateStuff/Goals.ttl#this",
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"classOrder": 5,
|
|
649
|
+
"termType": "NamedNode",
|
|
650
|
+
"value": "https://alice.example.com/privateStuff/workingOn.ttl#this",
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"classOrder": 5,
|
|
654
|
+
"termType": "NamedNode",
|
|
655
|
+
"value": "https://club.example.com/publicStuff/actionItems.ttl#this",
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
"classOrder": 5,
|
|
659
|
+
"termType": "NamedNode",
|
|
660
|
+
"value": "https://club.example.com/project4/clubIssues.ttl#this",
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"classOrder": 5,
|
|
664
|
+
"termType": "NamedNode",
|
|
665
|
+
"value": "https://club.example.com/privateStuff/ToDo.ttl#this",
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
"classOrder": 5,
|
|
669
|
+
"termType": "NamedNode",
|
|
670
|
+
"value": "https://club.example.com/privateStuff/Goals.ttl#this",
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
"classOrder": 5,
|
|
674
|
+
"termType": "NamedNode",
|
|
675
|
+
"value": "https://club.example.com/privateStuff/tasks.ttl#this",
|
|
676
|
+
},
|
|
677
|
+
]
|
|
678
|
+
|
|
679
|
+
describe('getAppInstances', () => {
|
|
680
|
+
it('exists', () => {
|
|
681
|
+
expect(getAppInstances).toBeInstanceOf(Function)
|
|
722
682
|
})
|
|
683
|
+
it('finds trackers', async () => {
|
|
684
|
+
const result = await getAppInstances(store, Tracker)
|
|
685
|
+
expect(result).toEqual(TRACKERS)
|
|
686
|
+
expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
|
|
687
|
+
})
|
|
688
|
+
it('finds images in containers', async () => {
|
|
689
|
+
const result = await getAppInstances(store, Image)
|
|
690
|
+
expect(result.length).toEqual(3)
|
|
691
|
+
expect(result).toEqual(uniqueNodes(result)) // shoud have no dups
|
|
692
|
+
expect(result.map(x => x.uri).join()).toEqual("https://alice.example.com/profile/Photos/photo1.png,https://alice.example.com/profile/Photos/photo2.png,https://alice.example.com/profile/Photos/photo3.png")
|
|
693
|
+
})
|
|
694
|
+
})
|
|
723
695
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
})
|
|
728
|
-
it('adds a registration', async () => {
|
|
729
|
-
const instance = sym(Alice.doc().uri + 'trackers/myToDo.ttl#this')
|
|
730
|
-
const index = AlicePublicTypeIndex
|
|
731
|
-
const result = await registerInstanceInTypeIndex(store, instance, index, klass)
|
|
732
|
-
expect(result.doc()).toEqual(index)
|
|
733
|
-
expect(store.any(result, ns.solid('forClass'), null, index)).toEqual(klass)
|
|
734
|
-
expect(store.any(result, ns.solid('instance'), null, index)).toEqual(instance)
|
|
735
|
-
expect(store.holds(result, ns.rdf('type'), ns.solid('TypeRegistration'), index)).toEqual(true)
|
|
736
|
-
expect(requests[0].url).toEqual(index.uri)
|
|
737
|
-
})
|
|
696
|
+
describe('registerInstanceInTypeIndex', () => {
|
|
697
|
+
it('exists', () => {
|
|
698
|
+
expect(registerInstanceInTypeIndex).toBeInstanceOf(Function)
|
|
738
699
|
})
|
|
700
|
+
it('adds a registration', async () => {
|
|
701
|
+
const instance = sym(Alice.doc().uri + 'trackers/myToDo.ttl#this')
|
|
702
|
+
const index = AlicePublicTypeIndex
|
|
703
|
+
const result = await registerInstanceInTypeIndex(store, instance, index, klass)
|
|
704
|
+
expect(result.doc()).toEqual(index)
|
|
705
|
+
expect(store.any(result, ns.solid('forClass'), null, index)).toEqual(klass)
|
|
706
|
+
expect(store.any(result, ns.solid('instance'), null, index)).toEqual(instance)
|
|
707
|
+
expect(store.holds(result, ns.rdf('type'), ns.solid('TypeRegistration'), index)).toEqual(true)
|
|
708
|
+
expect(requests[0].url).toEqual(index.uri)
|
|
709
|
+
})
|
|
710
|
+
})
|
|
739
711
|
|
|
740
712
|
})
|