forked from SolidOS/solid-logic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainer.test.ts
More file actions
58 lines (52 loc) · 1.94 KB
/
container.test.ts
File metadata and controls
58 lines (52 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @jest-environment jsdom
*
*/
import { UpdateManager, Store, Fetcher, sym } from "rdflib";
import { createContainerLogic } from "../src/util/containerLogic";
import { alice } from "./helpers/dataSetup";
window.$SolidTestEnvironment = { username: alice.uri }
describe("Container", () => {
let store
let containerLogic
beforeEach(() => {
fetchMock.resetMocks()
store = new Store()
store.fetcher = new Fetcher(store, { fetch: fetch });
store.updater = new UpdateManager(store);
containerLogic = createContainerLogic(store)
})
it("getContainerMembers - When container has some containment triples", async () => {
containerHasSomeContainmentTriples()
const containerMembers = await containerLogic.getContainerMembers(sym('https://container.com/'));
const result = containerMembers.map(oneResult => oneResult.value)
expect(result.sort()).toEqual([
'https://container.com/foo.txt',
'https://container.com/bar/'
].sort());
});
it.skip("getContainerMembers- When container is empty - Resolves to an empty array", async () => {
jest.setTimeout(2000)
containerIsEmpty();
const result = await containerLogic.getContainerMembers(sym('https://container.com/'));
expect(result).toEqual([]);
});
function containerIsEmpty() {
fetchMock.mockOnceIf(
"https://com/",
"", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
{
headers: { "Content-Type": "text/turtle" },
}
);
}
function containerHasSomeContainmentTriples() {
fetchMock.mockOnceIf(
"https://container.com/",
"<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .",
{
headers: { "Content-Type": "text/turtle" },
}
);
}
})