|
1 | 1 | import ComunicaEngine from '../src/ComunicaEngine'; |
2 | 2 |
|
3 | 3 | import { mockHttp } from './util'; |
4 | | -import { namedNode, defaultGraph } from '@rdfjs/data-model'; |
| 4 | +import { namedNode, defaultGraph, quad } from '@rdfjs/data-model'; |
| 5 | +import { Store } from 'n3'; |
5 | 6 | import { Readable } from 'stream'; |
6 | 7 |
|
7 | 8 | const SELECT_TYPES = ` |
@@ -195,6 +196,57 @@ describe('An ComunicaEngine instance with a default source', () => { |
195 | 196 | }); |
196 | 197 | }); |
197 | 198 |
|
| 199 | +describe('A ComunicaEngine instance with an rdfjs source (in list)', () => { |
| 200 | + const store = new Store([ |
| 201 | + quad( |
| 202 | + namedNode('http://example.org/Jesse'), |
| 203 | + namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), |
| 204 | + namedNode('http://xmlns.com/foaf/0.1/Person'), |
| 205 | + ), |
| 206 | + ]); |
| 207 | + |
| 208 | + const engine = new ComunicaEngine([store]); |
| 209 | + |
| 210 | + it('yields results for a SELECT query', async () => { |
| 211 | + const result = engine.execute(SELECT_TYPES); |
| 212 | + expect(await readAll(result)).toHaveLength(1); |
| 213 | + }); |
| 214 | +}); |
| 215 | + |
| 216 | +describe('A ComunicaEngine instance with an rdfjs source', () => { |
| 217 | + const store = new Store([ |
| 218 | + quad( |
| 219 | + namedNode('http://example.org/Jesse'), |
| 220 | + namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), |
| 221 | + namedNode('http://xmlns.com/foaf/0.1/Person'), |
| 222 | + ), |
| 223 | + ]); |
| 224 | + |
| 225 | + const engine = new ComunicaEngine(store); |
| 226 | + |
| 227 | + it('yields results for a SELECT query', async () => { |
| 228 | + const result = engine.execute(SELECT_TYPES); |
| 229 | + expect(await readAll(result)).toHaveLength(1); |
| 230 | + }); |
| 231 | +}); |
| 232 | + |
| 233 | +describe('A ComunicaEngine instance with an rdfjs source (as input to execute)', () => { |
| 234 | + const store = new Store([ |
| 235 | + quad( |
| 236 | + namedNode('http://example.org/Jesse'), |
| 237 | + namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), |
| 238 | + namedNode('http://xmlns.com/foaf/0.1/Person'), |
| 239 | + ), |
| 240 | + ]); |
| 241 | + |
| 242 | + const engine = new ComunicaEngine(); |
| 243 | + |
| 244 | + it('yields results for a SELECT query', async () => { |
| 245 | + const result = engine.execute(SELECT_TYPES, store); |
| 246 | + expect(await readAll(result)).toHaveLength(1); |
| 247 | + }); |
| 248 | +}); |
| 249 | + |
198 | 250 | describe('An ComunicaEngine instance with a default source that errors', () => { |
199 | 251 | const engine = new ComunicaEngine(Promise.reject(new Error('my error'))); |
200 | 252 |
|
|
0 commit comments