Skip to content

Commit 4ce9b09

Browse files
committed
Add test scripts for #45.
1 parent d883519 commit 4ce9b09

File tree

2 files changed

+47
-81
lines changed

2 files changed

+47
-81
lines changed

demo/user.html

+31-81
Original file line numberDiff line numberDiff line change
@@ -8,86 +8,36 @@
88
<script src="solid-query-ldflex.bundle.js"></script>
99
</head>
1010
<body>
11-
<h1>Your profile</h1>
12-
<button id="session">Loading…</button>
13-
14-
<h2>Personal details</h2>
15-
<dl>
16-
<dt>Name</dt>
17-
<dd id="name"></dd>
18-
<dt>First</dt>
19-
<dd id="firstName"></dd>
20-
<dt>Last</dt>
21-
<dd id="lastName"></dd>
22-
<dt>Birthday</dt>
23-
<dd id="birthday"></dd>
24-
<dt>Homepage</dt>
25-
<dd id="homepage"></dd>
26-
</dl>
27-
28-
<h2>Solid</h2>
29-
<dl>
30-
<dt>OIDC issuer</dt>
31-
<dd id="oidcIssuer"></dd>
32-
<dt>Storage</dt>
33-
<dd id="storage"></dd>
34-
<dt>Inbox</dt>
35-
<dd id="inbox"></dd>
36-
<dt>Preferences</dt>
37-
<dd id="prefs"></dd>
38-
<dt>Public type index</dt>
39-
<dd id="public"></dd>
40-
<dt>Private type index</dt>
41-
<dd id="private"></dd>
42-
</dl>
43-
44-
<h2>Friends</h2>
45-
<div id="friends"></div>
46-
47-
<!-- Showing user info -->
48-
<script>
49-
document.addEventListener('DOMContentLoaded', async () => {
50-
const user = solid.data.user;
51-
52-
show('name', await user.name);
53-
show('firstName', await user.firstName);
54-
show('lastName', await user.lastName);
55-
show('birthday', await user.birthday);
56-
show('homepage', await user.homepage);
57-
show('oidcIssuer', await user.oidcIssuer);
58-
show('storage', await user.storage);
59-
show('inbox', await user.inbox);
60-
show('prefs', await user.preferences);
61-
show('public', await user.publicTypeIndex);
62-
show('private', await user.privateTypeIndex);
63-
64-
for await (const name of user.friends.firstName)
65-
show('friends', name);
66-
});
67-
68-
function show(id, text) {
69-
const element = document.getElementById(id);
70-
element.innerText += text + '\n';
71-
}
72-
</script>
73-
74-
<!-- Logging in and out -->
75-
<script>
76-
const button = document.getElementById('session');
77-
let loggedIn = false;
78-
79-
solid.auth.trackSession(session =>
80-
button.innerText = (loggedIn = !!session) ? 'Log out' : 'Log in');
81-
82-
button.addEventListener('click', async () => {
83-
if (loggedIn)
84-
solid.auth.logout()
85-
else {
86-
const session = await solid.auth.popupLogin({ popupUri: 'popup.html' });
87-
if (session)
88-
window.location.reload();
89-
}
90-
});
91-
</script>
11+
<pre id="pre">
12+
</pre>
13+
<script>
14+
const times = {};
15+
const pre = document.getElementById("pre");
16+
function time(label) {
17+
times[label] = Date.now();
18+
}
19+
function timeEnd(label) {
20+
const delta = Date.now () - times[label];
21+
pre.innerText += `${label}: ${delta}ms\n`;
22+
}
23+
// console.time = time;
24+
// console.timeEnd = timeEnd;
25+
26+
(async function() {
27+
const container = solid.data["https://apiprod.happy-dev.fr/clients/"];
28+
console.time('total');
29+
console.time(container);
30+
await container.ldp_contains;
31+
console.timeEnd(container)
32+
for await (const r of container.ldp_contains) {
33+
console.time(r);
34+
await r['rdfs:label'];
35+
console.timeEnd(r);
36+
}
37+
console.timeEnd('total');
38+
})()
39+
40+
41+
</script>
9242
</body>
9343
</html>

test.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { default: data } = require('.');
2+
const solid = { data };
3+
4+
(async function() {
5+
const container = solid.data["https://apiprod.happy-dev.fr/clients/"];
6+
console.time('total');
7+
console.time(container);
8+
await container.ldp_contains;
9+
console.timeEnd(container)
10+
for await (const r of container.ldp_contains) {
11+
console.time(r);
12+
await r['rdfs:label'];
13+
console.timeEnd(r);
14+
}
15+
console.timeEnd('total');
16+
})()

0 commit comments

Comments
 (0)