solid-logic 3.0.9-f327aa58 → 3.0.9-f51524a8

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.
Files changed (102) hide show
  1. package/babel.config.js +6 -0
  2. package/eslint.config.js +23 -24
  3. package/jest.config.js +15 -8
  4. package/lib/acl/aclLogic.d.ts +2 -2
  5. package/lib/acl/aclLogic.d.ts.map +1 -1
  6. package/lib/authSession/authSession.d.ts.map +1 -1
  7. package/lib/authn/SolidAuthnLogic.d.ts +3 -3
  8. package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
  9. package/lib/authn/authUtil.d.ts +1 -1
  10. package/lib/chat/chatLogic.d.ts +1 -1
  11. package/lib/inbox/inboxLogic.d.ts +1 -1
  12. package/lib/inbox/inboxLogic.d.ts.map +1 -1
  13. package/lib/index.d.ts +1 -1
  14. package/lib/index.d.ts.map +1 -1
  15. package/lib/logic/CustomError.d.ts.map +1 -1
  16. package/lib/logic/solidLogic.d.ts +2 -2
  17. package/lib/logic/solidLogic.d.ts.map +1 -1
  18. package/lib/profile/profileLogic.d.ts +1 -1
  19. package/lib/solid-logic.js +107 -0
  20. package/lib/solid-logic.js.map +1 -0
  21. package/lib/types.d.ts +2 -2
  22. package/lib/util/containerLogic.d.ts +1 -1
  23. package/lib/util/containerLogic.d.ts.map +1 -1
  24. package/lib/util/debug.d.ts.map +1 -1
  25. package/lib/util/utilityLogic.d.ts +1 -1
  26. package/lib/util/utilityLogic.d.ts.map +1 -1
  27. package/lib/util/utils.d.ts +1 -1
  28. package/lib/util/utils.d.ts.map +1 -1
  29. package/package.json +39 -16
  30. package/rollup.config.js +29 -0
  31. package/src/acl/aclLogic.ts +8 -8
  32. package/src/authSession/authSession.ts +7 -1
  33. package/src/authn/SolidAuthnLogic.ts +7 -8
  34. package/src/authn/authUtil.ts +1 -1
  35. package/src/chat/chatLogic.ts +75 -75
  36. package/src/inbox/inboxLogic.ts +19 -19
  37. package/src/index.ts +1 -1
  38. package/src/logic/CustomError.ts +6 -6
  39. package/src/logic/solidLogic.ts +22 -22
  40. package/src/logic/solidLogicSingleton.ts +3 -3
  41. package/src/profile/profileLogic.ts +22 -22
  42. package/src/typeIndex/typeIndexLogic.ts +7 -7
  43. package/src/types.ts +2 -2
  44. package/src/util/containerLogic.ts +15 -15
  45. package/src/util/debug.ts +4 -8
  46. package/src/util/utilityLogic.ts +18 -18
  47. package/src/util/utils.ts +12 -12
  48. package/src/versionInfo.ts +32 -0
  49. package/test/aclLogic.test.ts +5 -5
  50. package/test/authUtil.test.ts +1 -1
  51. package/test/chatLogic.test.ts +160 -154
  52. package/test/container.test.ts +23 -23
  53. package/test/helpers/dataSetup.ts +2 -1
  54. package/test/helpers/setup.ts +8 -3
  55. package/test/inboxLogic.test.ts +101 -110
  56. package/test/logic.test.ts +2 -2
  57. package/test/profileLogic.test.ts +35 -33
  58. package/test/solidAuthLogic.test.ts +1 -1
  59. package/test/typeIndexLogic.test.ts +71 -71
  60. package/test/utilityLogic.test.ts +46 -45
  61. package/test/utils.test.ts +11 -11
  62. package/timestamp.sh +13 -0
  63. package/tsconfig.json +5 -3
  64. package/tsconfig.test.json +8 -0
  65. package/lib/acl/aclLogic.js +0 -168
  66. package/lib/acl/aclLogic.js.map +0 -1
  67. package/lib/authSession/authSession.js +0 -6
  68. package/lib/authSession/authSession.js.map +0 -1
  69. package/lib/authn/SolidAuthnLogic.js +0 -193
  70. package/lib/authn/SolidAuthnLogic.js.map +0 -1
  71. package/lib/authn/authUtil.js +0 -105
  72. package/lib/authn/authUtil.js.map +0 -1
  73. package/lib/chat/chatLogic.js +0 -272
  74. package/lib/chat/chatLogic.js.map +0 -1
  75. package/lib/inbox/inboxLogic.js +0 -139
  76. package/lib/inbox/inboxLogic.js.map +0 -1
  77. package/lib/index.js +0 -29
  78. package/lib/index.js.map +0 -1
  79. package/lib/issuer/issuerLogic.js +0 -52
  80. package/lib/issuer/issuerLogic.js.map +0 -1
  81. package/lib/logic/CustomError.js +0 -89
  82. package/lib/logic/CustomError.js.map +0 -1
  83. package/lib/logic/solidLogic.js +0 -102
  84. package/lib/logic/solidLogic.js.map +0 -1
  85. package/lib/logic/solidLogicSingleton.js +0 -94
  86. package/lib/logic/solidLogicSingleton.js.map +0 -1
  87. package/lib/profile/profileLogic.js +0 -259
  88. package/lib/profile/profileLogic.js.map +0 -1
  89. package/lib/typeIndex/typeIndexLogic.js +0 -399
  90. package/lib/typeIndex/typeIndexLogic.js.map +0 -1
  91. package/lib/types.js +0 -3
  92. package/lib/types.js.map +0 -1
  93. package/lib/util/containerLogic.js +0 -102
  94. package/lib/util/containerLogic.js.map +0 -1
  95. package/lib/util/debug.js +0 -40
  96. package/lib/util/debug.js.map +0 -1
  97. package/lib/util/ns.js +0 -44
  98. package/lib/util/ns.js.map +0 -1
  99. package/lib/util/utilityLogic.js +0 -284
  100. package/lib/util/utilityLogic.js.map +0 -1
  101. package/lib/util/utils.js +0 -47
  102. package/lib/util/utils.js.map +0 -1
@@ -2,91 +2,97 @@
2
2
  * @jest-environment jsdom
3
3
  *
4
4
  */
5
- import { UpdateManager, Store, Fetcher } from "rdflib";
6
- import { createAclLogic } from "../src/acl/aclLogic";
7
- import { createChatLogic } from '../src/chat/chatLogic';
8
- import { createProfileLogic } from "../src/profile/profileLogic";
9
- import { createContainerLogic } from "../src/util/containerLogic";
10
- import { createUtilityLogic } from "../src/util/utilityLogic";
11
- import { alice, bob } from "./helpers/dataSetup";
5
+ import { UpdateManager, Store, Fetcher } from 'rdflib'
6
+ import { createAclLogic } from '../src/acl/aclLogic'
7
+ import { createChatLogic } from '../src/chat/chatLogic'
8
+ import { createProfileLogic } from '../src/profile/profileLogic'
9
+ import { createContainerLogic } from '../src/util/containerLogic'
10
+ import { createUtilityLogic } from '../src/util/utilityLogic'
11
+ import { alice, bob } from './helpers/dataSetup'
12
+
13
+ declare global {
14
+ interface Window {
15
+ $SolidTestEnvironment?: { username: string }
16
+ }
17
+ }
12
18
 
13
19
  window.$SolidTestEnvironment = { username: alice.uri }
14
20
 
15
- describe("Chat logic", () => {
16
- let chatLogic;
17
- let store;
21
+ describe('Chat logic', () => {
22
+ let chatLogic
23
+ let store
18
24
  beforeEach(() => {
19
- fetchMock.resetMocks();
20
- fetchMock.mockResponse("Not Found", {
25
+ fetchMock.resetMocks()
26
+ fetchMock.mockResponse('Not Found', {
21
27
  status: 404,
22
- });
28
+ })
23
29
  store = new Store()
24
- store.fetcher = new Fetcher(store, { fetch: fetch });
25
- store.updater = new UpdateManager(store);
30
+ store.fetcher = new Fetcher(store, { fetch: fetch })
31
+ store.updater = new UpdateManager(store)
26
32
  const authn = {
27
33
  currentUser: () => {
28
- return alice;
34
+ return alice
29
35
  },
30
- };
36
+ }
31
37
  const util = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
32
38
  chatLogic = createChatLogic(store, createProfileLogic(store, authn, util))
33
- });
39
+ })
34
40
 
35
- describe("get chat, without creating", () => {
36
- describe("when no chat exists yet", () => {
37
- let result;
41
+ describe('get chat, without creating', () => {
42
+ describe('when no chat exists yet', () => {
43
+ let result
38
44
  beforeEach(async () => {
39
- aliceHasValidProfile();
40
- noChatWithBobExists();
41
- result = await chatLogic.getChat(bob, false);
42
- });
43
- it("does not return a chat", async () => {
44
- expect(result).toBeNull();
45
- });
46
- it("loaded the current user profile", () => {
45
+ aliceHasValidProfile()
46
+ noChatWithBobExists()
47
+ result = await chatLogic.getChat(bob, false)
48
+ })
49
+ it('does not return a chat', async () => {
50
+ expect(result).toBeNull()
51
+ })
52
+ it('loaded the current user profile', () => {
47
53
  expect(fetchMock.mock.calls[0][0]).toBe(
48
- "https://alice.example.com/profile/card.ttl"
49
- );
50
- });
51
- it("tried to load the chat document", () => {
54
+ 'https://alice.example.com/profile/card.ttl'
55
+ )
56
+ })
57
+ it('tried to load the chat document', () => {
52
58
  expect(fetchMock.mock.calls[1][0]).toBe(
53
- "https://alice.example.com/IndividualChats/bob.example.com/index.ttl"
54
- );
55
- });
56
- it("has no additional fetch requests", () => {
57
- expect(fetchMock.mock.calls.length).toBe(2);
58
- });
59
- });
60
- });
59
+ 'https://alice.example.com/IndividualChats/bob.example.com/index.ttl'
60
+ )
61
+ })
62
+ it('has no additional fetch requests', () => {
63
+ expect(fetchMock.mock.calls.length).toBe(2)
64
+ })
65
+ })
66
+ })
61
67
 
62
- describe("get chat, create if missing", () => {
63
- describe("when no chat exists yet", () => {
64
- let result;
68
+ describe('get chat, create if missing', () => {
69
+ describe('when no chat exists yet', () => {
70
+ let result
65
71
  beforeEach(async () => {
66
72
  Date.now = jest.fn(() =>
67
73
  new Date(Date.UTC(2021, 1, 6, 10, 11, 12)).valueOf()
68
- );
69
- aliceHasValidProfile();
70
- noChatWithBobExists();
71
- chatWithBobCanBeCreated();
72
- bobHasAnInbox();
73
- invitationCanBeSent();
74
- chatContainerIsFound();
75
- chatContainerAclCanBeSet();
76
- editablePrivateTypeIndexIsFound();
77
- privateTypeIndexIsUpdated();
78
- result = await chatLogic.getChat(bob, true);
79
- });
80
- it("returns the chat URI based on the invitee's WebID", () => {
74
+ )
75
+ aliceHasValidProfile()
76
+ noChatWithBobExists()
77
+ chatWithBobCanBeCreated()
78
+ bobHasAnInbox()
79
+ invitationCanBeSent()
80
+ chatContainerIsFound()
81
+ chatContainerAclCanBeSet()
82
+ editablePrivateTypeIndexIsFound()
83
+ privateTypeIndexIsUpdated()
84
+ result = await chatLogic.getChat(bob, true)
85
+ })
86
+ it('returns the chat URI based on the invitee\'s WebID', () => {
81
87
  expect(result.uri).toBe(
82
- "https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this"
83
- );
84
- });
85
- it("created a chat document", () => {
88
+ 'https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this'
89
+ )
90
+ })
91
+ it('created a chat document', () => {
86
92
  const request = getRequestTo(
87
- "PUT",
88
- "https://alice.example.com/IndividualChats/bob.example.com/index.ttl"
89
- );
93
+ 'PUT',
94
+ 'https://alice.example.com/IndividualChats/bob.example.com/index.ttl'
95
+ )
90
96
  expect(request.body).toBe(`@prefix : <#>.
91
97
  @prefix dc: <http://purl.org/dc/elements/1.1/>.
92
98
  @prefix meeting: <http://www.w3.org/ns/pim/meeting#>.
@@ -98,13 +104,13 @@ describe("Chat logic", () => {
98
104
  dc:author c:me;
99
105
  dc:created "2021-02-06T10:11:12Z"^^xsd:dateTime;
100
106
  dc:title "Chat channel".
101
- `);
102
- });
103
- it("allowed Bob to participate in the chat by adding an ACL", () => {
107
+ `)
108
+ })
109
+ it('allowed Bob to participate in the chat by adding an ACL', () => {
104
110
  const request = getRequestTo(
105
- "PUT",
106
- "https://alice.example.com/IndividualChats/bob.example.com/.acl"
107
- );
111
+ 'PUT',
112
+ 'https://alice.example.com/IndividualChats/bob.example.com/.acl'
113
+ )
108
114
  expect(request.body).toBe(`
109
115
  @prefix acl: <http://www.w3.org/ns/auth/acl#>.
110
116
  <#owner>
@@ -121,59 +127,59 @@ describe("Chat logic", () => {
121
127
  acl:default <.>;
122
128
  acl:mode
123
129
  acl:Read, acl:Append.
124
- `);
125
- });
126
- it("sent an invitation to invitee inbox", () => {
127
- const request = getRequestTo("POST", "https://bob.example.com/inbox");
130
+ `)
131
+ })
132
+ it('sent an invitation to invitee inbox', () => {
133
+ const request = getRequestTo('POST', 'https://bob.example.com/inbox')
128
134
  expect(request.body).toContain(`
129
135
  <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
130
136
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#seeAlso> <https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this> .
131
- `);
132
- });
133
- it("added the new chat to private type index", () => {
137
+ `)
138
+ })
139
+ it('added the new chat to private type index', () => {
134
140
  const request = getRequestTo(
135
- "PATCH",
136
- "https://alice.example.com/settings/privateTypeIndex.ttl"
137
- );
141
+ 'PATCH',
142
+ 'https://alice.example.com/settings/privateTypeIndex.ttl'
143
+ )
138
144
  expect(request.body)
139
145
  .toBe(`INSERT DATA { <https://alice.example.com/settings/privateTypeIndex.ttl#id1612606272000> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/solid/terms#TypeRegistration> .
140
146
  <https://alice.example.com/settings/privateTypeIndex.ttl#id1612606272000> <http://www.w3.org/ns/solid/terms#forClass> <http://www.w3.org/ns/pim/meeting#LongChat> .
141
147
  <https://alice.example.com/settings/privateTypeIndex.ttl#id1612606272000> <http://www.w3.org/ns/solid/terms#instance> <https://alice.example.com/IndividualChats/bob.example.com/index.ttl#this> .
142
148
  }
143
- `);
144
- });
145
- it("has no additional fetch requests", () => {
146
- expect(fetchMock.mock.calls.length).toBe(9);
147
- });
148
- });
149
- });
149
+ `)
150
+ })
151
+ it('has no additional fetch requests', () => {
152
+ expect(fetchMock.mock.calls.length).toBe(9)
153
+ })
154
+ })
155
+ })
150
156
 
151
- describe("possible errors", () => {
152
- it("profile does not link to storage", async () => {
153
- fetchMock.mockOnceIf("https://alice.example.com/profile/card.ttl", "<><><>.", {
157
+ describe('possible errors', () => {
158
+ it('profile does not link to storage', async () => {
159
+ fetchMock.mockOnceIf('https://alice.example.com/profile/card.ttl', '<><><>.', {
154
160
  headers: {
155
- "Content-Type": "text/turtle",
161
+ 'Content-Type': 'text/turtle',
156
162
  },
157
- });
158
- const expectedError = new Error("User pod root not found!");
159
- await expect(chatLogic.getChat(bob, false)).rejects.toEqual(expectedError);
160
- });
163
+ })
164
+ const expectedError = new Error('User pod root not found!')
165
+ await expect(chatLogic.getChat(bob, false)).rejects.toEqual(expectedError)
166
+ })
161
167
 
162
- it("invitee inbox not found", async () => {
163
- aliceHasValidProfile();
164
- noChatWithBobExists();
165
- chatWithBobCanBeCreated();
166
- bobDoesNotHaveAnInbox();
168
+ it('invitee inbox not found', async () => {
169
+ aliceHasValidProfile()
170
+ noChatWithBobExists()
171
+ chatWithBobCanBeCreated()
172
+ bobDoesNotHaveAnInbox()
167
173
  const expectedError = new Error(
168
- "Invitee inbox not found! https://bob.example.com/profile/card.ttl#me"
169
- );
170
- await expect(chatLogic.getChat(bob, true)).rejects.toEqual(expectedError);
171
- });
172
- });
174
+ 'Invitee inbox not found! https://bob.example.com/profile/card.ttl#me'
175
+ )
176
+ await expect(chatLogic.getChat(bob, true)).rejects.toEqual(expectedError)
177
+ })
178
+ })
173
179
 
174
180
  function aliceHasValidProfile() {
175
181
  fetchMock.mockOnceIf(
176
- "https://alice.example.com/profile/card.ttl",
182
+ 'https://alice.example.com/profile/card.ttl',
177
183
  `
178
184
  <https://alice.example.com/profile/card.ttl#me>
179
185
  <http://www.w3.org/ns/pim/space#storage> <https://alice.example.com/> ;
@@ -181,136 +187,136 @@ describe("Chat logic", () => {
181
187
  .`,
182
188
  {
183
189
  headers: {
184
- "Content-Type": "text/turtle",
190
+ 'Content-Type': 'text/turtle',
185
191
  },
186
192
  }
187
- );
193
+ )
188
194
  }
189
195
 
190
196
  function noChatWithBobExists() {
191
197
  return fetchMock.mockOnceIf(
192
198
  ({ url, method }) =>
193
- url === "https://alice.example.com/IndividualChats/bob.example.com/index.ttl" &&
194
- method === "GET",
195
- "Not found",
199
+ url === 'https://alice.example.com/IndividualChats/bob.example.com/index.ttl' &&
200
+ method === 'GET',
201
+ 'Not found',
196
202
  {
197
203
  status: 404,
198
204
  }
199
- );
205
+ )
200
206
  }
201
207
 
202
208
  function chatWithBobCanBeCreated() {
203
209
  return fetchMock.mockOnceIf(
204
210
  ({ url, method }) =>
205
- url === "https://alice.example.com/IndividualChats/bob.example.com/index.ttl" &&
206
- method === "PUT",
207
- "Created",
211
+ url === 'https://alice.example.com/IndividualChats/bob.example.com/index.ttl' &&
212
+ method === 'PUT',
213
+ 'Created',
208
214
  {
209
215
  status: 201,
210
216
  }
211
- );
217
+ )
212
218
  }
213
219
 
214
220
  function bobHasAnInbox() {
215
221
  fetchMock.mockOnceIf(
216
- "https://bob.example.com/profile/card.ttl",
217
- "<https://bob.example.com/profile/card.ttl#me><http://www.w3.org/ns/ldp#inbox><https://bob.example.com/inbox>.",
222
+ 'https://bob.example.com/profile/card.ttl',
223
+ '<https://bob.example.com/profile/card.ttl#me><http://www.w3.org/ns/ldp#inbox><https://bob.example.com/inbox>.',
218
224
  {
219
- headers: { "Content-Type": "text/turtle" },
225
+ headers: { 'Content-Type': 'text/turtle' },
220
226
  }
221
- );
227
+ )
222
228
  }
223
229
 
224
230
  function bobDoesNotHaveAnInbox() {
225
- fetchMock.mockOnceIf("https://bob.example.com/profile/card.ttl", "<><><>.", {
231
+ fetchMock.mockOnceIf('https://bob.example.com/profile/card.ttl', '<><><>.', {
226
232
  headers: {
227
- "Content-Type": "text/turtle",
233
+ 'Content-Type': 'text/turtle',
228
234
  },
229
- });
235
+ })
230
236
  }
231
237
 
232
238
  function invitationCanBeSent() {
233
239
  return fetchMock.mockOnceIf(
234
240
  ({ url, method }) =>
235
- url === "https://bob.example.com/inbox" && method === "POST",
236
- "Created",
241
+ url === 'https://bob.example.com/inbox' && method === 'POST',
242
+ 'Created',
237
243
  {
238
244
  status: 201,
239
245
  headers: {
240
246
  location:
241
- "https://bob.example.com/inbox/22373339-6cc0-49fc-b69e-0402edda6e4e.ttl",
247
+ 'https://bob.example.com/inbox/22373339-6cc0-49fc-b69e-0402edda6e4e.ttl',
242
248
  },
243
249
  }
244
- );
250
+ )
245
251
  }
246
252
 
247
253
  function chatContainerIsFound() {
248
254
  return fetchMock.mockOnceIf(
249
255
  ({ url, method }) =>
250
- url === "https://alice.example.com/IndividualChats/bob.example.com/" &&
251
- method === "GET",
252
- "<><><>.",
256
+ url === 'https://alice.example.com/IndividualChats/bob.example.com/' &&
257
+ method === 'GET',
258
+ '<><><>.',
253
259
  {
254
260
  status: 200,
255
261
  headers: {
256
- "Content-Type": "text/turtle",
262
+ 'Content-Type': 'text/turtle',
257
263
  Link: '<.acl>; rel="acl"',
258
264
  },
259
265
  }
260
- );
266
+ )
261
267
  }
262
268
 
263
269
  function chatContainerAclCanBeSet() {
264
270
  return fetchMock.mockOnceIf(
265
271
  ({ url, method }) =>
266
- url === "https://alice.example.com/IndividualChats/bob.example.com/.acl" &&
267
- method === "PUT",
268
- "Created",
272
+ url === 'https://alice.example.com/IndividualChats/bob.example.com/.acl' &&
273
+ method === 'PUT',
274
+ 'Created',
269
275
  {
270
276
  status: 201,
271
277
  }
272
- );
278
+ )
273
279
  }
274
280
 
275
281
  function editablePrivateTypeIndexIsFound() {
276
282
  return fetchMock.mockOnceIf(
277
283
  ({ url, method }) =>
278
- url === "https://alice.example.com/settings/privateTypeIndex.ttl" &&
279
- method === "GET",
280
- "<><><>.",
284
+ url === 'https://alice.example.com/settings/privateTypeIndex.ttl' &&
285
+ method === 'GET',
286
+ '<><><>.',
281
287
  {
282
288
  status: 200,
283
289
  headers: {
284
- "Content-Type": "text/turtle",
285
- "wac-allow": 'user="read write append control",public=""',
286
- "ms-author-via": "SPARQL",
290
+ 'Content-Type': 'text/turtle',
291
+ 'wac-allow': 'user="read write append control",public=""',
292
+ 'ms-author-via': 'SPARQL',
287
293
  },
288
294
  }
289
- );
295
+ )
290
296
  }
291
297
 
292
298
  function privateTypeIndexIsUpdated() {
293
299
  return fetchMock.mockOnceIf(
294
300
  ({ url, method }) =>
295
- url === "https://alice.example.com/settings/privateTypeIndex.ttl" &&
296
- method === "PATCH",
297
- "OK",
301
+ url === 'https://alice.example.com/settings/privateTypeIndex.ttl' &&
302
+ method === 'PATCH',
303
+ 'OK',
298
304
  {
299
305
  status: 200,
300
306
  }
301
- );
307
+ )
302
308
  }
303
309
 
304
310
  function getRequestTo(
305
- method: "GET" | "PUT" | "POST" | "DELETE" | "PATCH",
311
+ method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'PATCH',
306
312
  url: string
307
313
  ): RequestInit {
308
314
  const call = fetchMock.mock.calls.find(
309
315
  (it) => it[0] === url && method === it[1]?.method
310
- );
311
- expect(call).not.toBeNull();
312
- const request = call?.[1];
313
- expect(request).not.toBeNull();
314
- return request!;
316
+ )
317
+ expect(call).not.toBeNull()
318
+ const request = call?.[1]
319
+ expect(request).not.toBeNull()
320
+ return request!
315
321
  }
316
- });
322
+ })
@@ -2,57 +2,57 @@
2
2
  * @jest-environment jsdom
3
3
  *
4
4
  */
5
- import { UpdateManager, Store, Fetcher, sym } from "rdflib";
6
- import { createContainerLogic } from "../src/util/containerLogic";
7
- import { alice } from "./helpers/dataSetup";
5
+ import { UpdateManager, Store, Fetcher, sym } from 'rdflib'
6
+ import { createContainerLogic } from '../src/util/containerLogic'
7
+ import { alice } from './helpers/dataSetup'
8
8
 
9
9
  window.$SolidTestEnvironment = { username: alice.uri }
10
10
 
11
- describe("Container", () => {
11
+ describe('Container', () => {
12
12
  let store
13
13
  let containerLogic
14
14
  beforeEach(() => {
15
15
  fetchMock.resetMocks()
16
16
  store = new Store()
17
- store.fetcher = new Fetcher(store, { fetch: fetch });
18
- store.updater = new UpdateManager(store);
17
+ store.fetcher = new Fetcher(store, { fetch: fetch })
18
+ store.updater = new UpdateManager(store)
19
19
  containerLogic = createContainerLogic(store)
20
20
  })
21
21
 
22
- it("getContainerMembers - When container has some containment triples", async () => {
22
+ it('getContainerMembers - When container has some containment triples', async () => {
23
23
  containerHasSomeContainmentTriples()
24
- const containerMembers = await containerLogic.getContainerMembers(sym('https://container.com/'));
24
+ const containerMembers = await containerLogic.getContainerMembers(sym('https://container.com/'))
25
25
  const result = containerMembers.map(oneResult => oneResult.value)
26
26
  expect(result.sort()).toEqual([
27
27
  'https://container.com/foo.txt',
28
28
  'https://container.com/bar/'
29
- ].sort());
30
- });
31
- it.skip("getContainerMembers- When container is empty - Resolves to an empty array", async () => {
29
+ ].sort())
30
+ })
31
+ it.skip('getContainerMembers- When container is empty - Resolves to an empty array', async () => {
32
32
  jest.setTimeout(2000)
33
- containerIsEmpty();
34
- const result = await containerLogic.getContainerMembers(sym('https://container.com/'));
35
- expect(result).toEqual([]);
36
- });
33
+ containerIsEmpty()
34
+ const result = await containerLogic.getContainerMembers(sym('https://container.com/'))
35
+ expect(result).toEqual([])
36
+ })
37
37
 
38
38
  function containerIsEmpty() {
39
39
  fetchMock.mockOnceIf(
40
- "https://com/",
41
- "", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
40
+ 'https://com/',
41
+ '', // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
42
42
  {
43
- headers: { "Content-Type": "text/turtle" },
43
+ headers: { 'Content-Type': 'text/turtle' },
44
44
  }
45
- );
45
+ )
46
46
  }
47
47
 
48
48
  function containerHasSomeContainmentTriples() {
49
49
  fetchMock.mockOnceIf(
50
- "https://container.com/",
51
- "<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .",
50
+ 'https://container.com/',
51
+ '<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .',
52
52
  {
53
- headers: { "Content-Type": "text/turtle" },
53
+ headers: { 'Content-Type': 'text/turtle' },
54
54
  }
55
- );
55
+ )
56
56
 
57
57
  }
58
58
  })
@@ -46,7 +46,8 @@ const AliceProfileFile = alice.doc()
46
46
  const AlicePreferencesFile = sym('https://alice.example.com/settings/prefs.ttl')
47
47
  const AlicePublicTypeIndex = sym('https://alice.example.com/profile/public-type-index.ttl')
48
48
  const AlicePrivateTypeIndex = sym('https://alice.example.com/settings/private-type-index.ttl')
49
- const AlicePhotoFolder = sym(alice.dir().uri + "Photos/")
49
+ const aliceDir = alice.dir();
50
+ const AlicePhotoFolder = sym((aliceDir && aliceDir.uri ? aliceDir.uri : "") + "Photos/")
50
51
  const AliceProfile = `
51
52
  <#me> a vcard:Individual;
52
53
  space:preferencesFile ${AlicePreferencesFile};
@@ -1,8 +1,13 @@
1
1
  import { error, log, trace, warn } from '../../src/util/debug'
2
2
  import fetchMock from "jest-fetch-mock";
3
- import { TextEncoder, TextDecoder } from 'util'
4
- global.TextEncoder = TextEncoder
5
- global.TextDecoder = TextDecoder
3
+ import { TextEncoder as UtilTextEncoder, TextDecoder as UtilTextDecoder } from 'util'
4
+
5
+ if (typeof global.TextEncoder === 'undefined') {
6
+ global.TextEncoder = UtilTextEncoder as unknown as { new (): TextEncoder; prototype: TextEncoder }
7
+ }
8
+ if (typeof global.TextDecoder === 'undefined') {
9
+ global.TextDecoder = UtilTextDecoder as unknown as { new (): TextDecoder; prototype: TextDecoder }
10
+ }
6
11
 
7
12
 
8
13
  fetchMock.enableMocks();