@traqula/test-utils 0.0.23 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Traqula Test utils
2
2
 
3
+ [![npm version](https://badge.fury.io/js/@traqula%2Ftest-utils.svg)](https://www.npmjs.com/package/@traqula/test-utils)
4
+
3
5
  Traqula test utils contains some developer dependencies for testing packages and engines from the Traqula project.
4
6
 
5
7
  ## Installation
@@ -1,278 +1,260 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var Sparql11NotesTest_exports = {};
20
- __export(Sparql11NotesTest_exports, {
21
- importSparql11NoteTests: () => importSparql11NoteTests
22
- });
23
- module.exports = __toCommonJS(Sparql11NotesTest_exports);
24
- var import_vitest = require("vitest");
25
- function importSparql11NoteTests(parser, dataFactory) {
26
- function testErroneousQuery(query, _errorMsg) {
27
- return ({ expect }) => {
28
- let error;
29
- try {
30
- parser.parse(query);
31
- } catch (e) {
32
- error = e;
33
- }
34
- expect(error).not.toBeUndefined();
35
- expect(error).toBeInstanceOf(Error);
36
- };
37
- }
38
- (0, import_vitest.it)("should throw an error on an invalid query", testErroneousQuery("invalid", "Parse error on line 1"));
39
- import_vitest.it.skip("should throw an error on a projection of ungrouped variable", testErroneousQuery("PREFIX : <http://www.example.org/> SELECT ?o WHERE { ?s ?p ?o } GROUP BY ?s", "Projection of ungrouped variable (?o)"));
40
- (0, import_vitest.it)("should throw an error on a values class with LESS variables than value", testErroneousQuery("SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }", "Number of dataBlockValues does not match number of variables. Too much values."));
41
- (0, import_vitest.it)("should throw an error on a values class with MORE variables than value", testErroneousQuery("SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }", "Number of dataBlockValues does not match number of variables. Too few values."));
42
- (0, import_vitest.it)("should NOT throw on a values class with correct amount of values", ({ expect }) => {
43
- const query = "SELECT * WHERE { } VALUES ( ?S ) { ( true ) }";
44
- expect(parser.parse(query)).toMatchObject({});
45
- });
46
- import_vitest.it.skip("should throw an error on an invalid selectscope", testErroneousQuery("SELECT (1 AS ?X ) { SELECT (2 AS ?X ) {} }", "Target id of 'AS' (?X) already used in subquery"));
47
- import_vitest.it.skip("should throw an error on bind to variable in scope", testErroneousQuery("SELECT * { ?s ?p ?o BIND(?o AS ?o) }", "Target id of 'AS' (?X) already used in subquery"));
48
- (0, import_vitest.it)("should parse when not ending in newline", ({ expect }) => {
49
- const query = "select?s{?s?p?o}#wow, what a query";
50
- expect(parser.parse(query)).toMatchObject({});
51
- });
52
- (0, import_vitest.it)("should preserve BGP and filter pattern order", ({ expect }) => {
53
- const query = 'SELECT * { ?s ?p "1" . FILTER(true) . ?s ?p "2" }';
54
- expect(parser.parse(query)).toMatchObject({
55
- where: {
56
- patterns: [
57
- { subType: "bgp" },
58
- { subType: "filter" },
59
- { subType: "bgp" }
60
- ]
61
- }
62
- });
63
- });
64
- (0, import_vitest.it)("should throw an error on an aggregate function within an aggregate function", testErroneousQuery("SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }", "An aggregate function is not allowed within an aggregate function"));
65
- (0, import_vitest.describe)("with pre-defined prefixes", () => {
66
- const prefixes = { a: "ex:abc#", b: "ex:def#" };
67
- import_vitest.it.skip("should use those prefixes", ({ expect }) => {
68
- const query = 'SELECT * { a:a b:b "" }';
69
- expect(parser.parse(query, { prefixes })).toMatchObject({
70
- where: [
71
- {
72
- triples: [
73
- {
74
- subject: dataFactory.namedNode("ex:abc#a"),
75
- predicate: dataFactory.namedNode("ex:def#b"),
76
- object: dataFactory.literal("")
77
- }
78
- ]
79
- }
80
- ]
81
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importSparql11NoteTests = importSparql11NoteTests;
4
+ const vitest_1 = require("vitest");
5
+ function importSparql11NoteTests(parser, DF) {
6
+ function testErroneousQuery(query, _errorMsg) {
7
+ return ({ expect }) => {
8
+ let error;
9
+ try {
10
+ parser.parse(query);
11
+ }
12
+ catch (e) {
13
+ error = e;
14
+ }
15
+ expect(error).not.toBeUndefined();
16
+ expect(error).toBeInstanceOf(Error);
17
+ // Expect(error.message).toContain(errorMsg);
18
+ };
19
+ }
20
+ (0, vitest_1.it)('should throw an error on an invalid query', testErroneousQuery('invalid', 'Parse error on line 1'));
21
+ vitest_1.it.skip('should throw an error on a projection of ungrouped variable', testErroneousQuery('PREFIX : <http://www.example.org/> SELECT ?o WHERE { ?s ?p ?o } GROUP BY ?s', 'Projection of ungrouped variable (?o)'));
22
+ (0, vitest_1.it)('should throw an error on a values class with LESS variables than value', testErroneousQuery('SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }', 'Number of dataBlockValues does not match number of variables. Too much values.'));
23
+ (0, vitest_1.it)('should throw an error on a values class with MORE variables than value', testErroneousQuery('SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }', 'Number of dataBlockValues does not match number of variables. Too few values.'));
24
+ (0, vitest_1.it)('should NOT throw on a values class with correct amount of values', ({ expect }) => {
25
+ const query = 'SELECT * WHERE { } VALUES ( ?S ) { ( true ) }';
26
+ expect(parser.parse(query)).toMatchObject({});
82
27
  });
83
- import_vitest.it.skip("should allow temporarily overriding prefixes", ({ expect }) => {
84
- const query = 'PREFIX a: <ex:xyz#> SELECT * { a:a b:b "" }';
85
- expect(parser.parse(query, { prefixes })).toMatchObject({
86
- where: [
87
- {
88
- triples: [{
89
- subject: dataFactory.namedNode("ex:xyz#a"),
90
- predicate: dataFactory.namedNode("ex:def#b"),
91
- object: dataFactory.literal("")
92
- }]
93
- }
94
- ]
95
- });
96
- const query2 = 'SELECT * { a:a b:b "" }';
97
- expect(parser.parse(query2, { prefixes })).toMatchObject({
98
- where: [
99
- {
100
- triples: [{
101
- subject: dataFactory.namedNode("ex:abc#a"),
102
- predicate: dataFactory.namedNode("ex:def#b"),
103
- object: dataFactory.literal("")
104
- }]
105
- }
106
- ]
107
- });
28
+ vitest_1.it.skip('should throw an error on an invalid selectscope', testErroneousQuery('SELECT (1 AS ?X ) { SELECT (2 AS ?X ) {} }', 'Target id of \'AS\' (?X) already used in subquery'));
29
+ vitest_1.it.skip('should throw an error on bind to variable in scope', testErroneousQuery('SELECT * { ?s ?p ?o BIND(?o AS ?o) }', 'Target id of \'AS\' (?X) already used in subquery'));
30
+ (0, vitest_1.it)('should parse when not ending in newline', ({ expect }) => {
31
+ const query = 'select?s{?s?p?o}#wow, what a query';
32
+ expect(parser.parse(query)).toMatchObject({});
108
33
  });
109
- (0, import_vitest.it)("should not change the original prefixes", ({ expect }) => {
110
- expect(prefixes).toEqual({ a: "ex:abc#", b: "ex:def#" });
34
+ (0, vitest_1.it)('should preserve BGP and filter pattern order', ({ expect }) => {
35
+ const query = 'SELECT * { ?s ?p "1" . FILTER(true) . ?s ?p "2" }';
36
+ expect(parser.parse(query)).toMatchObject({
37
+ where: {
38
+ patterns: [
39
+ { subType: 'bgp' },
40
+ { subType: 'filter' },
41
+ { subType: 'bgp' },
42
+ ],
43
+ },
44
+ });
111
45
  });
112
- });
113
- (0, import_vitest.describe)("with pre-defined base IRI", () => {
114
- const context = { baseIRI: "http://ex.org/" };
115
- import_vitest.it.skip("contains the base", ({ expect }) => {
116
- const query = "SELECT * { ?s ?p ?o }";
117
- expect(parser.parse(query, context)).toMatchObject({
118
- base: "http://ex.org/"
119
- });
46
+ (0, vitest_1.it)('should throw an error on an aggregate function within an aggregate function', testErroneousQuery('SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }', 'An aggregate function is not allowed within an aggregate function'));
47
+ (0, vitest_1.describe)('with pre-defined prefixes', () => {
48
+ const prefixes = { a: 'ex:abc#', b: 'ex:def#' };
49
+ vitest_1.it.skip('should use those prefixes', ({ expect }) => {
50
+ const query = 'SELECT * { a:a b:b "" }';
51
+ expect(parser.parse(query, { prefixes })).toMatchObject({
52
+ where: [
53
+ {
54
+ triples: [
55
+ {
56
+ subject: DF.namedNode('ex:abc#a'),
57
+ predicate: DF.namedNode('ex:def#b'),
58
+ object: DF.literal(''),
59
+ },
60
+ ],
61
+ },
62
+ ],
63
+ });
64
+ });
65
+ vitest_1.it.skip('should allow temporarily overriding prefixes', ({ expect }) => {
66
+ const query = 'PREFIX a: <ex:xyz#> SELECT * { a:a b:b "" }';
67
+ expect(parser.parse(query, { prefixes })).toMatchObject({
68
+ where: [{
69
+ triples: [{
70
+ subject: DF.namedNode('ex:xyz#a'),
71
+ predicate: DF.namedNode('ex:def#b'),
72
+ object: DF.literal(''),
73
+ }],
74
+ },
75
+ ],
76
+ });
77
+ const query2 = 'SELECT * { a:a b:b "" }';
78
+ expect(parser.parse(query2, { prefixes })).toMatchObject({
79
+ where: [{
80
+ triples: [{
81
+ subject: DF.namedNode('ex:abc#a'),
82
+ predicate: DF.namedNode('ex:def#b'),
83
+ object: DF.literal(''),
84
+ }],
85
+ },
86
+ ],
87
+ });
88
+ });
89
+ (0, vitest_1.it)('should not change the original prefixes', ({ expect }) => {
90
+ expect(prefixes).toEqual({ a: 'ex:abc#', b: 'ex:def#' });
91
+ });
120
92
  });
121
- import_vitest.it.skip("using prefixed as relative iri", ({ expect }) => {
122
- const context2 = { baseIRI: "http://ex.org/apl" };
123
- const query = `
93
+ (0, vitest_1.describe)('with pre-defined base IRI', () => {
94
+ const context = { baseIRI: 'http://ex.org/' };
95
+ vitest_1.it.skip('contains the base', ({ expect }) => {
96
+ const query = 'SELECT * { ?s ?p ?o }';
97
+ expect(parser.parse(query, context)).toMatchObject({
98
+ base: 'http://ex.org/',
99
+ });
100
+ });
101
+ vitest_1.it.skip('using prefixed as relative iri', ({ expect }) => {
102
+ const context = { baseIRI: 'http://ex.org/apl' };
103
+ const query = `
124
104
  CONSTRUCT
125
105
  FROM <data.ttl>
126
106
  WHERE { ?s ?p ?o }
127
107
  `;
128
- expect(parser.parse(query, context2)).toMatchObject({
129
- from: {
130
- default: [
131
- dataFactory.namedNode("http://ex.org/data.ttl")
132
- ]
133
- }
134
- });
135
- });
136
- import_vitest.it.skip("should use the base IRI", ({ expect }) => {
137
- const query = 'SELECT * { <> <#b> "" }';
138
- const result = {
139
- subject: dataFactory.namedNode("http://ex.org/"),
140
- predicate: dataFactory.namedNode("http://ex.org/#b"),
141
- object: dataFactory.literal("")
142
- };
143
- expect(parser.parse(query, context)).toMatchObject({
144
- where: [{ triples: [result] }]
145
- });
108
+ expect(parser.parse(query, context)).toMatchObject({
109
+ from: {
110
+ default: [
111
+ DF.namedNode('http://ex.org/data.ttl'),
112
+ ],
113
+ },
114
+ });
115
+ });
116
+ vitest_1.it.skip('should use the base IRI', ({ expect }) => {
117
+ const query = 'SELECT * { <> <#b> "" }';
118
+ const result = {
119
+ subject: DF.namedNode('http://ex.org/'),
120
+ predicate: DF.namedNode('http://ex.org/#b'),
121
+ object: DF.literal(''),
122
+ };
123
+ expect(parser.parse(query, context)).toMatchObject({
124
+ where: [{ triples: [result] }],
125
+ });
126
+ });
127
+ vitest_1.it.skip('should work after a previous query failed', ({ expect }) => {
128
+ const badQuery = 'SELECT * { <> <#b> "" } invalid!';
129
+ expect(() => parser.parse(badQuery, context)).toThrow(Error);
130
+ const goodQuery = 'SELECT * { <> <#b> "" }';
131
+ const context = { baseIRI: 'http://ex2.org/' };
132
+ const result = {
133
+ subject: DF.namedNode('http://ex2.org/'),
134
+ predicate: DF.namedNode('http://ex2.org/#b'),
135
+ object: DF.literal(''),
136
+ };
137
+ const data = parser.parse(goodQuery, context);
138
+ expect(data).toMatchObject({
139
+ where: [{ triples: [result] }],
140
+ });
141
+ });
146
142
  });
147
- import_vitest.it.skip("should work after a previous query failed", ({ expect }) => {
148
- const badQuery = 'SELECT * { <> <#b> "" } invalid!';
149
- expect(() => parser.parse(badQuery, context2)).toThrow(Error);
150
- const goodQuery = 'SELECT * { <> <#b> "" }';
151
- const context2 = { baseIRI: "http://ex2.org/" };
152
- const result = {
153
- subject: dataFactory.namedNode("http://ex2.org/"),
154
- predicate: dataFactory.namedNode("http://ex2.org/#b"),
155
- object: dataFactory.literal("")
156
- };
157
- const data = parser.parse(goodQuery, context2);
158
- expect(data).toMatchObject({
159
- where: [{ triples: [result] }]
160
- });
161
- });
162
- });
163
- import_vitest.it.skip("should throw an error on relative IRIs if no base IRI is specified", testErroneousQuery("SELECT * { <a> <b> <c> }", "Cannot resolve relative IRI a because no base IRI was set."));
164
- (0, import_vitest.describe)("with group collapsing disabled", () => {
165
- import_vitest.it.skip("should keep explicit pattern group", ({ expect }) => {
166
- const query = "SELECT * WHERE { { ?s ?p ?o } ?a ?b ?c }";
167
- const result = [
168
- {
169
- type: "group",
170
- patterns: [
171
- {
172
- type: "bgp",
173
- triples: [
143
+ vitest_1.it.skip('should throw an error on relative IRIs if no base IRI is specified', testErroneousQuery('SELECT * { <a> <b> <c> }', 'Cannot resolve relative IRI a because no base IRI was set.'));
144
+ (0, vitest_1.describe)('with group collapsing disabled', () => {
145
+ vitest_1.it.skip('should keep explicit pattern group', ({ expect }) => {
146
+ const query = 'SELECT * WHERE { { ?s ?p ?o } ?a ?b ?c }';
147
+ const result = [
174
148
  {
175
- subject: dataFactory.variable("s"),
176
- predicate: dataFactory.variable("p"),
177
- object: dataFactory.variable("o")
178
- }
179
- ]
180
- }
181
- ]
182
- },
183
- {
184
- type: "bgp",
185
- triples: [
186
- {
187
- subject: dataFactory.variable("a"),
188
- predicate: dataFactory.variable("b"),
189
- object: dataFactory.variable("c")
190
- }
191
- ]
192
- }
193
- ];
194
- expect(parser.parse(query)).toMatchObject({ where: result });
195
- });
196
- import_vitest.it.skip("should still collapse immediate union groups", ({ expect }) => {
197
- const query = "SELECT * WHERE { { ?s ?p ?o } UNION { ?a ?b ?c } }";
198
- const result = [
199
- {
200
- type: "union",
201
- patterns: [{
202
- type: "bgp",
203
- triples: [{
204
- subject: {
205
- termType: "Variable",
206
- value: "s"
207
- },
208
- predicate: {
209
- termType: "Variable",
210
- value: "p"
211
- },
212
- object: {
213
- termType: "Variable",
214
- value: "o"
215
- }
216
- }]
217
- }, {
218
- type: "bgp",
219
- triples: [{
220
- subject: {
221
- termType: "Variable",
222
- value: "a"
223
- },
224
- predicate: {
225
- termType: "Variable",
226
- value: "b"
227
- },
228
- object: {
229
- termType: "Variable",
230
- value: "c"
231
- }
232
- }]
233
- }]
234
- }
235
- ];
236
- expect(parser.parse(query)).toMatchObject({ where: result });
237
- });
238
- });
239
- (0, import_vitest.describe)("for update queries", () => {
240
- (0, import_vitest.it)("should throw an error on blank nodes in DELETE clause", testErroneousQuery('DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }', "Detected illegal blank node in BGP"));
241
- (0, import_vitest.it)("should not throw on blank nodes in INSERT clause", ({ expect }) => {
242
- const query = 'INSERT { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }';
243
- expect(parser.parse(query)).toMatchObject({});
244
- });
245
- (0, import_vitest.it)("should throw an error on blank nodes in compact DELETE clause", testErroneousQuery("DELETE WHERE { _:a <ex:p> <ex:o> }", "Detected illegal blank node in BGP"));
246
- (0, import_vitest.it)("should throw an error on variables in DELETE DATA clause", testErroneousQuery("DELETE DATA { ?a <ex:p> <ex:o> }", "Detected illegal variable in BGP"));
247
- (0, import_vitest.it)("should throw an error on blank nodes in DELETE DATA clause", testErroneousQuery("DELETE DATA { _:a <ex:p> <ex:o> }", "Detected illegal blank node in BGP"));
248
- (0, import_vitest.it)("should throw an error on variables in DELETE DATA clause with GRAPH", testErroneousQuery("DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }", "Detected illegal variable in GRAPH"));
249
- (0, import_vitest.it)("should throw an error on variables in INSERT DATA clause", testErroneousQuery("INSERT DATA { ?a <ex:p> <ex:o> }", "Detected illegal variable in BGP"));
250
- (0, import_vitest.it)("should not throw on reused blank nodes in one INSERT DATA clause", ({ expect }) => {
251
- const query = "INSERT DATA { _:a <ex:p> <ex:o> . _:a <ex:p> <ex:o> . }";
252
- expect(parser.parse(query)).toMatchObject({});
149
+ type: 'group',
150
+ patterns: [
151
+ {
152
+ type: 'bgp',
153
+ triples: [
154
+ {
155
+ subject: DF.variable('s'),
156
+ predicate: DF.variable('p'),
157
+ object: DF.variable('o'),
158
+ },
159
+ ],
160
+ },
161
+ ],
162
+ },
163
+ {
164
+ type: 'bgp',
165
+ triples: [
166
+ {
167
+ subject: DF.variable('a'),
168
+ predicate: DF.variable('b'),
169
+ object: DF.variable('c'),
170
+ },
171
+ ],
172
+ },
173
+ ];
174
+ expect(parser.parse(query)).toMatchObject({ where: result });
175
+ });
176
+ vitest_1.it.skip('should still collapse immediate union groups', ({ expect }) => {
177
+ const query = 'SELECT * WHERE { { ?s ?p ?o } UNION { ?a ?b ?c } }';
178
+ const result = [
179
+ {
180
+ type: 'union',
181
+ patterns: [{
182
+ type: 'bgp',
183
+ triples: [{
184
+ subject: {
185
+ termType: 'Variable',
186
+ value: 's',
187
+ },
188
+ predicate: {
189
+ termType: 'Variable',
190
+ value: 'p',
191
+ },
192
+ object: {
193
+ termType: 'Variable',
194
+ value: 'o',
195
+ },
196
+ }],
197
+ }, {
198
+ type: 'bgp',
199
+ triples: [{
200
+ subject: {
201
+ termType: 'Variable',
202
+ value: 'a',
203
+ },
204
+ predicate: {
205
+ termType: 'Variable',
206
+ value: 'b',
207
+ },
208
+ object: {
209
+ termType: 'Variable',
210
+ value: 'c',
211
+ },
212
+ }],
213
+ }],
214
+ },
215
+ ];
216
+ expect(parser.parse(query)).toMatchObject({ where: result });
217
+ });
253
218
  });
254
- import_vitest.it.skip("should throw an error on reused blank nodes across INSERT DATA clauses", testErroneousQuery("INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { _:a <ex:p> <ex:o> }", "Detected reuse blank node across different INSERT DATA clauses"));
255
- import_vitest.it.skip("should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH", testErroneousQuery("INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }", "Detected reuse blank node across different INSERT DATA clauses"));
256
- (0, import_vitest.it)("should not throw on comment between INSERT and DATA", ({ expect }) => {
257
- const query = `INSERT
219
+ (0, vitest_1.describe)('for update queries', () => {
220
+ (0, vitest_1.it)('should throw an error on blank nodes in DELETE clause', testErroneousQuery('DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }', 'Detected illegal blank node in BGP'));
221
+ (0, vitest_1.it)('should not throw on blank nodes in INSERT clause', ({ expect }) => {
222
+ const query = 'INSERT { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> "Alan" . }';
223
+ // TODO: add proper test
224
+ expect(parser.parse(query)).toMatchObject({});
225
+ });
226
+ (0, vitest_1.it)('should throw an error on blank nodes in compact DELETE clause', testErroneousQuery('DELETE WHERE { _:a <ex:p> <ex:o> }', 'Detected illegal blank node in BGP'));
227
+ (0, vitest_1.it)('should throw an error on variables in DELETE DATA clause', testErroneousQuery('DELETE DATA { ?a <ex:p> <ex:o> }', 'Detected illegal variable in BGP'));
228
+ (0, vitest_1.it)('should throw an error on blank nodes in DELETE DATA clause', testErroneousQuery('DELETE DATA { _:a <ex:p> <ex:o> }', 'Detected illegal blank node in BGP'));
229
+ (0, vitest_1.it)('should throw an error on variables in DELETE DATA clause with GRAPH', testErroneousQuery('DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }', 'Detected illegal variable in GRAPH'));
230
+ (0, vitest_1.it)('should throw an error on variables in INSERT DATA clause', testErroneousQuery('INSERT DATA { ?a <ex:p> <ex:o> }', 'Detected illegal variable in BGP'));
231
+ (0, vitest_1.it)('should not throw on reused blank nodes in one INSERT DATA clause', ({ expect }) => {
232
+ const query = 'INSERT DATA { _:a <ex:p> <ex:o> . _:a <ex:p> <ex:o> . }';
233
+ // Todo: add proper test
234
+ expect(parser.parse(query)).toMatchObject({});
235
+ });
236
+ vitest_1.it.skip('should throw an error on reused blank nodes across INSERT DATA clauses', testErroneousQuery('INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { _:a <ex:p> <ex:o> }', 'Detected reuse blank node across different INSERT DATA clauses'));
237
+ vitest_1.it.skip('should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH', testErroneousQuery('INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }', 'Detected reuse blank node across different INSERT DATA clauses'));
238
+ (0, vitest_1.it)('should not throw on comment between INSERT and DATA', ({ expect }) => {
239
+ const query = `INSERT
258
240
  # Comment
259
241
  DATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;
260
- expect(parser.parse(query)).toMatchObject({});
261
- });
262
- (0, import_vitest.it)("should not throw on comment after INSERT that could be confused with DATA", ({ expect }) => {
263
- const query = `INSERT # DATA
242
+ // TODO: add proper test
243
+ expect(parser.parse(query)).toMatchObject({});
244
+ });
245
+ (0, vitest_1.it)('should not throw on comment after INSERT that could be confused with DATA', ({ expect }) => {
246
+ const query = `INSERT # DATA
264
247
  DATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;
265
- expect(parser.parse(query)).toMatchObject({});
248
+ // TODO: add proper test
249
+ expect(parser.parse(query)).toMatchObject({});
250
+ });
251
+ (0, vitest_1.it)('should throw an error on commented DATA after INSERT', testErroneousQuery('INSERT # DATA { GRAPH <ex:G> { <ex:s> <ex:p> \'o1\', \'o2\', \'o3\' } }', 'Parse error'));
252
+ });
253
+ (0, vitest_1.it)('should throw an error on unicode codepoint escaping in literal with partial surrogate pair', testErroneousQuery('SELECT * WHERE { ?s <ex:p> \'\uD800\' }', 'Invalid unicode codepoint of surrogate pair without corresponding codepoint'));
254
+ (0, vitest_1.it)('should not throw an error on unicode codepoint escaping in literal with complete surrogate pair', ({ expect }) => {
255
+ const query = 'SELECT * WHERE { ?s <ex:p> \'\uD800\uDFFF\' }';
256
+ // TODO: add proper test
257
+ expect(parser.parse(query)).toMatchObject({});
266
258
  });
267
- (0, import_vitest.it)("should throw an error on commented DATA after INSERT", testErroneousQuery("INSERT # DATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }", "Parse error"));
268
- });
269
- (0, import_vitest.it)("should throw an error on unicode codepoint escaping in literal with partial surrogate pair", testErroneousQuery("SELECT * WHERE { ?s <ex:p> '\uD800' }", "Invalid unicode codepoint of surrogate pair without corresponding codepoint"));
270
- (0, import_vitest.it)("should not throw an error on unicode codepoint escaping in literal with complete surrogate pair", ({ expect }) => {
271
- const query = "SELECT * WHERE { ?s <ex:p> '\u{103FF}' }";
272
- expect(parser.parse(query)).toMatchObject({});
273
- });
274
259
  }
275
- // Annotate the CommonJS export names for ESM import in node:
276
- 0 && (module.exports = {
277
- importSparql11NoteTests
278
- });
260
+ //# sourceMappingURL=Sparql11NotesTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sparql11NotesTest.js","sourceRoot":"","sources":["../../../lib/Sparql11NotesTest.ts"],"names":[],"mappings":";;AASA,0DA+VC;AAtWD,mCAAsC;AAOtC,SAAgB,uBAAuB,CAAC,MAAc,EAAE,EAAyB;IAC/E,SAAS,kBAAkB,CAAC,KAAa,EAAE,SAAiB;QAC1D,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACpB,IAAI,KAAU,CAAC;YACf,IAAI,CAAC;g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EAAE,EAAE;QACb,MAAM,KAAK,GAAG,+CAA+C,CAAC;QAC9D,wBAAwB;QACxB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { BaseQuad } from '@rdfjs/types';\nimport type { DataFactory } from 'rdf-data-factory';\nimport { describe, it } from 'vitest';\nimport type { TestFunction } from 'vitest';\n\ninterface Parser {\n parse: (query: string, context?: { prefixes?: Record<string, string>; baseIRI?: string }) => unknown;\n}\n\nexport function importSparql11NoteTests(parser: Parser, DF: DataFactory<BaseQuad>): void {\n function testErroneousQuery(query: string, _errorMsg: string): TestFunction<object> {\n return ({ expect }) => {\n let error: any;\n try {\n parser.parse(query);\n } catch (e) {\n error = e;\n }\n expect(error).not.toBeUndefined();\n expect(error).toBeInstanceOf(Error);\n // Expect(error.message).toContain(errorMsg);\n };\n }\n\n it('should throw an error on an invalid query', testErroneousQuery('invalid', 'Parse error on line 1'));\n\n it.skip('should throw an error on a projection of ungrouped variable', testErroneousQuery(\n 'PREFIX : <http://www.example.org/> SELECT ?o WHERE { ?s ?p ?o } GROUP BY ?s',\n 'Projection of ungrouped variable (?o)',\n ));\n\n it('should throw an error on a values class with LESS variables than value', testErroneousQuery(\n 'SELECT * WHERE { } VALUES ( ?S ) { ( true false ) }',\n 'Number of dataBlockValues does not match number of variables. Too much values.',\n ));\n\n it('should throw an error on a values class with MORE variables than value', testErroneousQuery(\n 'SELECT * WHERE { } VALUES ( ?S ?O ) { ( true ) }',\n 'Number of dataBlockValues does not match number of variables. Too few values.',\n ));\n\n it('should NOT throw on a values class with correct amount of values', ({ expect }) => {\n const query = 'SELECT * WHERE { } VALUES ( ?S ) { ( true ) }';\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it.skip('should throw an error on an invalid selectscope', testErroneousQuery(\n 'SELECT (1 AS ?X ) { SELECT (2 AS ?X ) {} }',\n 'Target id of \\'AS\\' (?X) already used in subquery',\n ));\n\n it.skip('should throw an error on bind to variable in scope', testErroneousQuery(\n 'SELECT * { ?s ?p ?o BIND(?o AS ?o) }',\n 'Target id of \\'AS\\' (?X) already used in subquery',\n ));\n\n it('should parse when not ending in newline', ({ expect }) => {\n const query = 'select?s{?s?p?o}#wow, what a query';\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should preserve BGP and filter pattern order', ({ expect }) => {\n const query = 'SELECT * { ?s ?p \"1\" . FILTER(true) . ?s ?p \"2\" }';\n expect(parser.parse(query)).toMatchObject({\n where: {\n patterns: [\n { subType: 'bgp' },\n { subType: 'filter' },\n { subType: 'bgp' },\n ],\n },\n });\n });\n\n it('should throw an error on an aggregate function within an aggregate function', testErroneousQuery(\n 'SELECT (SUM(COUNT(?lprice)) AS ?totalPrice) { }',\n 'An aggregate function is not allowed within an aggregate function',\n ));\n\n describe('with pre-defined prefixes', () => {\n const prefixes = { a: 'ex:abc#', b: 'ex:def#' };\n\n it.skip('should use those prefixes', ({ expect }) => {\n const query = 'SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query, { prefixes })).toMatchObject({\n where: [\n {\n triples: [\n {\n subject: DF.namedNode('ex:abc#a'),\n predicate: DF.namedNode('ex:def#b'),\n object: DF.literal(''),\n },\n ],\n },\n ],\n });\n });\n\n it.skip('should allow temporarily overriding prefixes', ({ expect }) => {\n const query = 'PREFIX a: <ex:xyz#> SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query, { prefixes })).toMatchObject({\n where: [{\n triples: [{\n subject: DF.namedNode('ex:xyz#a'),\n predicate: DF.namedNode('ex:def#b'),\n object: DF.literal(''),\n }],\n },\n ],\n });\n\n const query2 = 'SELECT * { a:a b:b \"\" }';\n expect(parser.parse(query2, { prefixes })).toMatchObject({\n where: [{\n triples: [{\n subject: DF.namedNode('ex:abc#a'),\n predicate: DF.namedNode('ex:def#b'),\n object: DF.literal(''),\n }],\n },\n ],\n });\n });\n\n it('should not change the original prefixes', ({ expect }) => {\n expect(prefixes).toEqual({ a: 'ex:abc#', b: 'ex:def#' });\n });\n });\n\n describe('with pre-defined base IRI', () => {\n const context = { baseIRI: 'http://ex.org/' };\n\n it.skip('contains the base', ({ expect }) => {\n const query = 'SELECT * { ?s ?p ?o }';\n expect(parser.parse(query, context)).toMatchObject({\n base: 'http://ex.org/',\n });\n });\n\n it.skip('using prefixed as relative iri', ({ expect }) => {\n const context = { baseIRI: 'http://ex.org/apl' };\n const query = `\nCONSTRUCT\nFROM <data.ttl>\nWHERE { ?s ?p ?o }\n`;\n expect(parser.parse(query, context)).toMatchObject({\n from: {\n default: [\n DF.namedNode('http://ex.org/data.ttl'),\n ],\n },\n });\n });\n\n it.skip('should use the base IRI', ({ expect }) => {\n const query = 'SELECT * { <> <#b> \"\" }';\n const result = {\n subject: DF.namedNode('http://ex.org/'),\n predicate: DF.namedNode('http://ex.org/#b'),\n object: DF.literal(''),\n };\n\n expect(parser.parse(query, context)).toMatchObject({\n where: [{ triples: [ result ]}],\n });\n });\n\n it.skip('should work after a previous query failed', ({ expect }) => {\n const badQuery = 'SELECT * { <> <#b> \"\" } invalid!';\n expect(() => parser.parse(badQuery, context)).toThrow(Error);\n\n const goodQuery = 'SELECT * { <> <#b> \"\" }';\n\n const context = { baseIRI: 'http://ex2.org/' };\n const result = {\n subject: DF.namedNode('http://ex2.org/'),\n predicate: DF.namedNode('http://ex2.org/#b'),\n object: DF.literal(''),\n };\n const data = parser.parse(goodQuery, context);\n expect(data).toMatchObject({\n where: [{ triples: [ result ]}],\n });\n });\n });\n\n it.skip('should throw an error on relative IRIs if no base IRI is specified', testErroneousQuery(\n 'SELECT * { <a> <b> <c> }',\n 'Cannot resolve relative IRI a because no base IRI was set.',\n ));\n\n describe('with group collapsing disabled', () => {\n it.skip('should keep explicit pattern group', ({ expect }) => {\n const query = 'SELECT * WHERE { { ?s ?p ?o } ?a ?b ?c }';\n const result = [\n {\n type: 'group',\n patterns: [\n {\n type: 'bgp',\n triples: [\n {\n subject: DF.variable('s'),\n predicate: DF.variable('p'),\n object: DF.variable('o'),\n },\n ],\n },\n ],\n },\n {\n type: 'bgp',\n triples: [\n {\n subject: DF.variable('a'),\n predicate: DF.variable('b'),\n object: DF.variable('c'),\n },\n ],\n },\n ];\n\n expect(parser.parse(query)).toMatchObject({ where: result });\n });\n\n it.skip('should still collapse immediate union groups', ({ expect }) => {\n const query = 'SELECT * WHERE { { ?s ?p ?o } UNION { ?a ?b ?c } }';\n\n const result = [\n {\n type: 'union',\n patterns: [{\n type: 'bgp',\n triples: [{\n subject: {\n termType: 'Variable',\n value: 's',\n },\n predicate: {\n termType: 'Variable',\n value: 'p',\n },\n object: {\n termType: 'Variable',\n value: 'o',\n },\n }],\n }, {\n type: 'bgp',\n triples: [{\n subject: {\n termType: 'Variable',\n value: 'a',\n },\n predicate: {\n termType: 'Variable',\n value: 'b',\n },\n object: {\n termType: 'Variable',\n value: 'c',\n },\n }],\n }],\n },\n ];\n\n expect(parser.parse(query)).toMatchObject({ where: result });\n });\n });\n\n describe('for update queries', () => {\n it('should throw an error on blank nodes in DELETE clause', testErroneousQuery(\n 'DELETE { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> \"Alan\" . }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should not throw on blank nodes in INSERT clause', ({ expect }) => {\n const query = 'INSERT { ?a <ex:knows> [] . } WHERE { ?a <ex:knows> \"Alan\" . }';\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should throw an error on blank nodes in compact DELETE clause', testErroneousQuery(\n 'DELETE WHERE { _:a <ex:p> <ex:o> }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should throw an error on variables in DELETE DATA clause', testErroneousQuery(\n 'DELETE DATA { ?a <ex:p> <ex:o> }',\n 'Detected illegal variable in BGP',\n ));\n\n it('should throw an error on blank nodes in DELETE DATA clause', testErroneousQuery(\n 'DELETE DATA { _:a <ex:p> <ex:o> }',\n 'Detected illegal blank node in BGP',\n ));\n\n it('should throw an error on variables in DELETE DATA clause with GRAPH', testErroneousQuery(\n 'DELETE DATA { GRAPH ?a { <ex:s> <ex:p> <ex:o> } }',\n 'Detected illegal variable in GRAPH',\n ));\n\n it('should throw an error on variables in INSERT DATA clause', testErroneousQuery(\n 'INSERT DATA { ?a <ex:p> <ex:o> }',\n 'Detected illegal variable in BGP',\n ));\n\n it('should not throw on reused blank nodes in one INSERT DATA clause', ({ expect }) => {\n const query = 'INSERT DATA { _:a <ex:p> <ex:o> . _:a <ex:p> <ex:o> . }';\n // Todo: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it.skip('should throw an error on reused blank nodes across INSERT DATA clauses', testErroneousQuery(\n 'INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { _:a <ex:p> <ex:o> }',\n 'Detected reuse blank node across different INSERT DATA clauses',\n ));\n\n it.skip('should throw an error on reused blank nodes across INSERT DATA clauses with GRAPH', testErroneousQuery(\n 'INSERT DATA { _:a <ex:p> <ex:o> }; INSERT DATA { GRAPH <ex:g> { _:a <ex:p> <ex:o> } }',\n 'Detected reuse blank node across different INSERT DATA clauses',\n ));\n\n it('should not throw on comment between INSERT and DATA', ({ expect }) => {\n const query = `INSERT\n# Comment\nDATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should not throw on comment after INSERT that could be confused with DATA', ({ expect }) => {\n const query = `INSERT # DATA\nDATA { GRAPH <ex:G> { <ex:s> <ex:p> 'o1', 'o2', 'o3' } }`;\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n });\n\n it('should throw an error on commented DATA after INSERT', testErroneousQuery(\n 'INSERT # DATA { GRAPH <ex:G> { <ex:s> <ex:p> \\'o1\\', \\'o2\\', \\'o3\\' } }',\n 'Parse error',\n ));\n });\n\n it('should throw an error on unicode codepoint escaping in literal with partial surrogate pair', testErroneousQuery(\n 'SELECT * WHERE { ?s <ex:p> \\'\\uD800\\' }',\n 'Invalid unicode codepoint of surrogate pair without corresponding codepoint',\n ));\n\n it(\n 'should not throw an error on unicode codepoint escaping in literal with complete surrogate pair',\n ({ expect }) => {\n const query = 'SELECT * WHERE { ?s <ex:p> \\'\\uD800\\uDFFF\\' }';\n // TODO: add proper test\n expect(parser.parse(query)).toMatchObject({});\n },\n );\n}\n"]}