|
1 | 1 | import { when } from "jest-when"; |
2 | | -import { sym } from "rdflib"; |
| 2 | +import { quad, sym } from "rdflib"; |
3 | 3 | import { Parser as SparqlParser, Update } from "sparqljs"; |
4 | 4 | import { AuthenticatedFetch, PodOsSession } from "./authentication"; |
5 | 5 | import { Store } from "./Store"; |
@@ -450,6 +450,32 @@ describe("Store", () => { |
450 | 450 | ); |
451 | 451 | }); |
452 | 452 | }); |
| 453 | + |
| 454 | + describe("findMembers", () => { |
| 455 | + it("finds instances of classes and subclasses", () => { |
| 456 | + const store = new Store({} as PodOsSession); |
| 457 | + store.graph.addAll([ |
| 458 | + quad( |
| 459 | + sym("http://recipe.test/1"), |
| 460 | + sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), |
| 461 | + sym("http://schema.org/Recipe"), |
| 462 | + ), |
| 463 | + quad( |
| 464 | + sym("http://recipe.test/RecipeClass"), |
| 465 | + sym("http://www.w3.org/2000/01/rdf-schema#subClassOf"), |
| 466 | + sym("http://schema.org/Recipe"), |
| 467 | + ), |
| 468 | + quad( |
| 469 | + sym("http://recipe.test/2"), |
| 470 | + sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), |
| 471 | + sym("http://recipe.test/RecipeClass"), |
| 472 | + ), |
| 473 | + ]); |
| 474 | + const members = store.findMembers("http://schema.org/Recipe"); |
| 475 | + expect(members).toContain("http://recipe.test/1"); |
| 476 | + expect(members).toContain("http://recipe.test/2"); |
| 477 | + }); |
| 478 | + }); |
453 | 479 | }); |
454 | 480 |
|
455 | 481 | export function thenSparqlUpdateIsSentToUrl( |
|
0 commit comments