|
1 | 1 | import { DateContainerQuery } from "./DateContainerQuery"; |
2 | | -import { graph, sym } from "rdflib"; |
| 2 | +import { graph, parse, sym } from "rdflib"; |
3 | 3 |
|
4 | 4 | describe(DateContainerQuery.name, () => { |
5 | 5 | describe("query latest", () => { |
@@ -68,5 +68,55 @@ describe(DateContainerQuery.name, () => { |
68 | 68 | ).queryLatest(); |
69 | 69 | expect(result).toEqual(null); |
70 | 70 | }); |
| 71 | + |
| 72 | + it("returns the container name with the latest year number", () => { |
| 73 | + const store = graph(); |
| 74 | + |
| 75 | + parse( |
| 76 | + ` |
| 77 | + @prefix ldp: <http://www.w3.org/ns/ldp#>. |
| 78 | + |
| 79 | + <> ldp:contains <2022/>, <2024/>, <2023/>. |
| 80 | + |
| 81 | + |
| 82 | + <2022/> a ldp:Container . |
| 83 | + <2024/> a ldp:Container . |
| 84 | + <2023/> a ldp:Container . |
| 85 | + `, |
| 86 | + store, |
| 87 | + "https://pod.test/container/", |
| 88 | + ); |
| 89 | + |
| 90 | + const result = new DateContainerQuery( |
| 91 | + sym("https://pod.test/container/"), |
| 92 | + store, |
| 93 | + ).queryLatest(); |
| 94 | + expect(result).toEqual(sym("https://pod.test/container/2024/")); |
| 95 | + }); |
| 96 | + |
| 97 | + it("returns the container name with the month / day number", () => { |
| 98 | + const store = graph(); |
| 99 | + |
| 100 | + parse( |
| 101 | + ` |
| 102 | + @prefix ldp: <http://www.w3.org/ns/ldp#>. |
| 103 | + |
| 104 | + <> ldp:contains <05/>, <08/>, <06/>. |
| 105 | + |
| 106 | + |
| 107 | + <05/> a ldp:Container . |
| 108 | + <08/> a ldp:Container . |
| 109 | + <06/> a ldp:Container . |
| 110 | + `, |
| 111 | + store, |
| 112 | + "https://pod.test/container/2024/", |
| 113 | + ); |
| 114 | + |
| 115 | + const result = new DateContainerQuery( |
| 116 | + sym("https://pod.test/container/2024/"), |
| 117 | + store, |
| 118 | + ).queryLatest(); |
| 119 | + expect(result).toEqual(sym("https://pod.test/container/2024/08/")); |
| 120 | + }); |
71 | 121 | }); |
72 | 122 | }); |
0 commit comments