Skip to content

Commit

Permalink
bookmarks-rdflib: use test-support from rdflib-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo-v committed Jul 10, 2024
1 parent b21376b commit 6ba0339
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 125 deletions.
3 changes: 2 additions & 1 deletion bookmarks/rdflib/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ const config: Config = {
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.ts$": [
"^.+\\.[tj]s$": [
"ts-jest",
{
useESM: true,
},
],
},
transformIgnorePatterns: ["node_modules/(?!(@solid-data-modules)/)"],
};

export default config;
13 changes: 12 additions & 1 deletion bookmarks/rdflib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bookmarks/rdflib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@
"typescript": "^5.4.5"
},
"dependencies": {
"short-unique-id": "^5.2.0"
"@solid-data-modules/rdflib-utils": "^0.2.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { BookmarksModuleRdfLib } from "../BookmarksModuleRdfLib";

import { generateId } from "../../generate-id";
import { expectPatchRequest } from "../../test-support/expectRequests";
import { Fetcher, graph, UpdateManager } from "rdflib";
import {
expectPatchRequest,
mockLdpContainer,
mockNotFound,
mockTurtleDocument,
} from "../../test-support/mockResponses";
} from "@solid-data-modules/rdflib-utils/test-support";
import { Fetcher, graph, UpdateManager } from "rdflib";

import { when } from "jest-when";

jest.mock("../../generate-id");
Expand Down Expand Up @@ -48,11 +49,17 @@ describe("create bookmark", () => {
expectPatchRequest(
authenticatedFetch,
"https://pod.test/alice/bookmarks/70501305",
`INSERT DATA { <https://pod.test/alice/bookmarks/70501305#it> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/01/bookmark#Bookmark> .
<https://pod.test/alice/bookmarks/70501305#it> <http://purl.org/dc/terms/title> "My favorite website" .
<https://pod.test/alice/bookmarks/70501305#it> <http://www.w3.org/2002/01/bookmark#recalls> <https://favorite.example> .
<https://pod.test/alice/bookmarks/70501305#it> <http://purl.org/dc/terms/created> "2024-01-02T03:04:05.678Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
}`,
`@prefix solid: <http://www.w3.org/ns/solid/terms#>.
@prefix ex: <http://www.example.org/terms#>.
_:patch
solid:inserts {
<https://pod.test/alice/bookmarks/70501305#it> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/01/bookmark#Bookmark> .
<https://pod.test/alice/bookmarks/70501305#it> <http://purl.org/dc/terms/title> "My favorite website" .
<https://pod.test/alice/bookmarks/70501305#it> <http://www.w3.org/2002/01/bookmark#recalls> <https://favorite.example> .
<https://pod.test/alice/bookmarks/70501305#it> <http://purl.org/dc/terms/created> "2024-01-02T03:04:05.678Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
}; a solid:InsertDeletePatch .`,
);
});

Expand Down Expand Up @@ -90,11 +97,17 @@ describe("create bookmark", () => {
expectPatchRequest(
authenticatedFetch,
"https://pod.test/alice/bookmarks",
`INSERT DATA { <https://pod.test/alice/bookmarks#f7a4eeb7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/01/bookmark#Bookmark> .
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://purl.org/dc/terms/title> "My favorite website" .
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://www.w3.org/2002/01/bookmark#recalls> <https://favorite.example> .
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://purl.org/dc/terms/created> "2024-01-02T03:04:05.678Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
}`,
`@prefix solid: <http://www.w3.org/ns/solid/terms#>.
@prefix ex: <http://www.example.org/terms#>.
_:patch
solid:inserts {
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/01/bookmark#Bookmark> .
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://purl.org/dc/terms/title> "My favorite website" .
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://www.w3.org/2002/01/bookmark#recalls> <https://favorite.example> .
<https://pod.test/alice/bookmarks#f7a4eeb7> <http://purl.org/dc/terms/created> "2024-01-02T03:04:05.678Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
}; a solid:InsertDeletePatch .`,
);
});
});
30 changes: 0 additions & 30 deletions bookmarks/rdflib/src/test-support/expectRequests.ts

This file was deleted.

73 changes: 0 additions & 73 deletions bookmarks/rdflib/src/test-support/mockResponses.ts

This file was deleted.

11 changes: 5 additions & 6 deletions bookmarks/rdflib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
"compilerOptions": {
"outDir": "dist",
"target": "es2020",
"lib": [
"es2020", "DOM"
],
"lib": ["es2020", "DOM"],
"module": "ES2020",
"moduleResolution": "Node",
"moduleResolution": "bundler",
"strict": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"declaration": true
"declaration": true,
"allowJs": true
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts", "src/test-support", "src/e2e-tests"],
"exclude": ["**/*.spec.ts", "src/e2e-tests"]
}

0 comments on commit 6ba0339

Please sign in to comment.