@@ -6,7 +6,7 @@ import {Readable} from "stream";
6
6
import { RdfDereferencer } from "../lib/RdfDereferencer" ;
7
7
import 'cross-fetch' ;
8
8
9
- import dereferencer from ".." ;
9
+ import { rdfDereferencer } from ".." ;
10
10
import { mocked } from 'ts-jest/utils' ;
11
11
12
12
// Mock fetch
@@ -40,18 +40,18 @@ describe('dereferencer', () => {
40
40
} ) ;
41
41
42
42
it ( 'should be an RdfDereferencer instance' , ( ) => {
43
- expect ( dereferencer ) . toBeInstanceOf ( RdfDereferencer ) ;
43
+ expect ( rdfDereferencer ) . toBeInstanceOf ( RdfDereferencer ) ;
44
44
} ) ;
45
45
46
46
it ( 'should error on 404 responses' , async ( ) => {
47
47
mockSetup ( { statusCode : 404 } ) ;
48
- return expect ( dereferencer . dereference ( 'http://example.org/' ) ) . rejects
48
+ return expect ( rdfDereferencer . dereference ( 'http://example.org/' ) ) . rejects
49
49
. toThrow ( new Error ( 'Could not retrieve http://example.org/ (HTTP status 404):\nempty response' ) ) ;
50
50
} ) ;
51
51
52
52
it ( 'should error on errors' , async ( ) => {
53
53
mockSetup ( { error : true } ) ;
54
- return expect ( dereferencer . dereference ( 'http://example.org/' ) ) . rejects
54
+ return expect ( rdfDereferencer . dereference ( 'http://example.org/' ) ) . rejects
55
55
. toThrow ( new Error ( 'fetch error' ) ) ;
56
56
} ) ;
57
57
@@ -62,7 +62,7 @@ describe('dereferencer', () => {
62
62
` ) ;
63
63
body . push ( null ) ;
64
64
mockSetup ( { statusCode : 200 , body, headers : { 'content-type' : 'text/turtle' } } ) ;
65
- const out = await dereferencer . dereference ( 'http://example.org/' ) ;
65
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' ) ;
66
66
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
67
67
expect ( out . url ) . toEqual ( 'http://example.org/' ) ;
68
68
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -80,7 +80,7 @@ describe('dereferencer', () => {
80
80
81
81
const myFetch : typeof fetch = async ( url ) => getMock ( { statusCode : 200 , body, headers : { 'content-type' : 'text/turtle' } } ) as any ;
82
82
83
- const out = await dereferencer . dereference ( 'http://example.org/' , { fetch : myFetch } ) ;
83
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' , { fetch : myFetch } ) ;
84
84
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
85
85
expect ( out . url ) . toEqual ( 'http://example.org/' ) ;
86
86
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -96,7 +96,7 @@ describe('dereferencer', () => {
96
96
` ) ;
97
97
body . push ( null ) ;
98
98
mockSetup ( { statusCode : 200 , body, url : 'http://example.org/bla.ttl' } ) ;
99
- const out = await dereferencer . dereference ( 'http://example.org/bla.ttl' ) ;
99
+ const out = await rdfDereferencer . dereference ( 'http://example.org/bla.ttl' ) ;
100
100
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
101
101
expect ( out . url ) . toEqual ( 'http://example.org/bla.ttl' ) ;
102
102
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -112,7 +112,7 @@ describe('dereferencer', () => {
112
112
` ) ;
113
113
body . push ( null ) ;
114
114
mockSetup ( { statusCode : 200 , body, headers : { 'content-type' : 'text/turtle' , 'content-location' : 'http://example.org/bla' } } ) ;
115
- const out = await dereferencer . dereference ( 'http://example.org/' ) ;
115
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' ) ;
116
116
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
117
117
expect ( out . url ) . toEqual ( 'http://example.org/' ) ;
118
118
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -128,7 +128,7 @@ describe('dereferencer', () => {
128
128
` ) ;
129
129
body . push ( null ) ;
130
130
mockSetup ( { statusCode : 200 , body, headers : { 'content-type' : 'text/turtle' } } ) ;
131
- const out = await dereferencer . dereference ( 'http://example.org/' ) ;
131
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' ) ;
132
132
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
133
133
expect ( out . url ) . toEqual ( 'http://example.org/' ) ;
134
134
return expect ( arrayifyStream ( out . data ) )
@@ -142,7 +142,7 @@ describe('dereferencer', () => {
142
142
` ) ;
143
143
body . push ( null ) ;
144
144
mockSetup ( { statusCode : 200 , body, headers : { 'content-type' : 'unknown' } } ) ;
145
- return expect ( dereferencer . dereference ( 'http://example.org/' ) ) . rejects
145
+ return expect ( rdfDereferencer . dereference ( 'http://example.org/' ) ) . rejects
146
146
. toThrow ( ) ;
147
147
} ) ;
148
148
@@ -159,7 +159,7 @@ describe('dereferencer', () => {
159
159
` ) ;
160
160
body . push ( null ) ;
161
161
mockSetup ( { statusCode : 200 , body, headers : { 'content-type' : 'application/ld+json' } } ) ;
162
- const out = await dereferencer . dereference ( 'http://example.org/' ) ;
162
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' ) ;
163
163
expect ( out . metadata ) . toBeFalsy ( ) ;
164
164
expect ( out . url ) . toEqual ( 'http://example.org/' ) ;
165
165
return expect ( arrayifyStream ( out . data ) )
@@ -177,7 +177,7 @@ describe('dereferencer', () => {
177
177
` ) ;
178
178
body . push ( null ) ;
179
179
mockSetup ( { statusCode : 200 , body, headers : new Headers ( { 'content-type' : 'text/turtle' } ) } ) ;
180
- const out = await dereferencer . dereference ( 'http://example.org/' , { method : 'GET' } ) ;
180
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' , { method : 'GET' } ) ;
181
181
expect ( fetch ) . toHaveBeenCalledWith ( 'http://example.org/' , {
182
182
agent : expect . anything ( ) ,
183
183
headers : expect . anything ( ) ,
@@ -195,7 +195,7 @@ describe('dereferencer', () => {
195
195
` ) ;
196
196
body . push ( null ) ;
197
197
mockSetup ( { statusCode : 200 , body, headers : new Headers ( { 'content-type' : 'text/turtle' } ) } ) ;
198
- const out = await dereferencer . dereference ( 'http://example.org/' , { headers : { _a : 'A' , _b : 'B' } } ) ;
198
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' , { headers : { _a : 'A' , _b : 'B' } } ) ;
199
199
expect ( fetch ) . toHaveBeenCalledWith ( 'http://example.org/' , {
200
200
agent : expect . anything ( ) ,
201
201
headers : expect . anything ( ) ,
@@ -215,7 +215,7 @@ describe('dereferencer', () => {
215
215
` ) ;
216
216
body . push ( null ) ;
217
217
mockSetup ( { statusCode : 200 , body, headers : new Headers ( { 'content-type' : 'text/turtle' } ) } ) ;
218
- const out = await dereferencer . dereference ( 'http://example.org/' , { method : 'POST' } ) ;
218
+ const out = await rdfDereferencer . dereference ( 'http://example.org/' , { method : 'POST' } ) ;
219
219
expect ( fetch ) . toHaveBeenCalledWith ( 'http://example.org/' , {
220
220
agent : expect . anything ( ) ,
221
221
headers : expect . anything ( ) ,
@@ -227,7 +227,7 @@ describe('dereferencer', () => {
227
227
} ) ;
228
228
229
229
it ( 'should handle relative local .ttl files' , async ( ) => {
230
- const out = await dereferencer . dereference ( 'test/assets/example.ttl' , { localFiles : true } ) ;
230
+ const out = await rdfDereferencer . dereference ( 'test/assets/example.ttl' , { localFiles : true } ) ;
231
231
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
232
232
expect ( out . url ) . toEqual ( join ( process . cwd ( ) , 'test/assets/example.ttl' ) ) ;
233
233
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -237,12 +237,12 @@ describe('dereferencer', () => {
237
237
} ) ;
238
238
239
239
it ( 'should error on relative local .ttl files without localFiles flag' , async ( ) => {
240
- await expect ( dereferencer . dereference ( 'test/assets/example.ttl' ) ) . rejects . toThrow (
240
+ await expect ( rdfDereferencer . dereference ( 'test/assets/example.ttl' ) ) . rejects . toThrow (
241
241
new Error ( 'Tried to dereference a local file without enabling localFiles option: test/assets/example.ttl' ) ) ;
242
242
} ) ;
243
243
244
244
it ( 'should handle absolute local .ttl files' , async ( ) => {
245
- const out = await dereferencer . dereference ( join ( process . cwd ( ) , 'test/assets/example.ttl' ) , { localFiles : true } ) ;
245
+ const out = await rdfDereferencer . dereference ( join ( process . cwd ( ) , 'test/assets/example.ttl' ) , { localFiles : true } ) ;
246
246
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
247
247
expect ( out . url ) . toEqual ( join ( process . cwd ( ) , 'test/assets/example.ttl' ) ) ;
248
248
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -252,7 +252,7 @@ describe('dereferencer', () => {
252
252
} ) ;
253
253
254
254
it ( 'should handle absolute local .shaclc files' , async ( ) => {
255
- const out = await dereferencer . dereference ( join ( process . cwd ( ) , 'test/assets/example.shaclc' ) , { localFiles : true } ) ;
255
+ const out = await rdfDereferencer . dereference ( join ( process . cwd ( ) , 'test/assets/example.shaclc' ) , { localFiles : true } ) ;
256
256
expect ( out . metadata . triples ) . toBeTruthy ( ) ;
257
257
expect ( out . url ) . toEqual ( join ( process . cwd ( ) , 'test/assets/example.shaclc' ) ) ;
258
258
return expect ( arrayifyStream ( out . data ) ) . resolves . toBeRdfIsomorphic ( [
@@ -262,7 +262,7 @@ describe('dereferencer', () => {
262
262
} ) ;
263
263
264
264
it ( 'should error on absolute local .ttl files without localFiles flag' , async ( ) => {
265
- await expect ( dereferencer . dereference ( join ( process . cwd ( ) , 'test/assets/example.ttl' ) ) ) . rejects . toThrow (
265
+ await expect ( rdfDereferencer . dereference ( join ( process . cwd ( ) , 'test/assets/example.ttl' ) ) ) . rejects . toThrow (
266
266
new Error ( 'Tried to dereference a local file without enabling localFiles option: '
267
267
+ join ( process . cwd ( ) , 'test/assets/example.ttl' ) ) ) ;
268
268
} ) ;
0 commit comments