Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
node_js:
- "8"
- "10"
- "12"
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ function rdfFetch (url, { factory = defaultFactory, formats = defaultFormats, ..
return rdfFetchLite(url, { factory, formats, ...options })
}

rdfFetch.Headers = rdfFetchLite.Headers

module.exports = rdfFetch
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Wrapper for fetch to simplify sending and receiving RDF data",
"main": "index.js",
"scripts": {
"test": "standard && jest"
"test": "standard && mocha"
},
"repository": {
"type": "git",
Expand All @@ -23,12 +23,12 @@
"homepage": "https://github.com/rdfjs-base/fetch",
"dependencies": {
"@rdfjs/dataset": "^1.0.1",
"@rdfjs/fetch-lite": "^2.0.1",
"@rdfjs/fetch-lite": "^2.1.0",
"@rdfjs/formats-common": "^2.0.1"
},
"devDependencies": {
"@rdfjs/sink-map": "^1.0.1",
"jest": "^24.9.0",
"mocha": "^7.1.1",
"nock": "^11.6.0",
"standard": "^14.3.1"
}
Expand Down
20 changes: 20 additions & 0 deletions test/Headers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { strictEqual } = require('assert')
const { describe, it } = require('mocha')
const { Headers } = require('..')

describe('Headers', () => {
it('should be a constructor', () => {
strictEqual(typeof Headers, 'function')
})

it('should implement the Headers interface', () => {
const headers = new Headers()

strictEqual(typeof headers.append, 'function')
strictEqual(typeof headers.delete, 'function')
strictEqual(typeof headers.entries, 'function')
strictEqual(typeof headers.get, 'function')
strictEqual(typeof headers.has, 'function')
strictEqual(typeof headers.set, 'function')
})
})
24 changes: 14 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* global describe, expect, it */

const { strictEqual } = require('assert')
const { describe, it } = require('mocha')
const nock = require('nock')
const rdf = require('@rdfjs/dataset')
const rdfFetch = require('..')
const SinkMap = require('@rdfjs/sink-map')

describe('@rdfjs/fetch', () => {
it('should be a function', () => {
expect(typeof rdfFetch).toBe('function')
strictEqual(typeof rdfFetch, 'function')
})

it('should return a Promise', () => {
const result = rdfFetch('http://example.org/')

expect(typeof result).toBe('object')
expect(typeof result.then).toBe('function')
strictEqual(typeof result, 'object')
strictEqual(typeof result.then, 'function')
})

it('should use formats common as default formats', async () => {
Expand All @@ -30,14 +30,18 @@ describe('@rdfjs/fetch', () => {

await rdfFetch('http://example.org/formats-common')

expect([
const mediaTypes = [
'application/ld+json',
'application/trig',
'application/n-quads',
'application/n-triples',
'text/n3',
'text/turtle'
].every(mediaType => accept.includes(mediaType))).toBe(true)
]

mediaTypes.forEach(mediaType => {
strictEqual(accept.includes(mediaType), true)
})
})

it('should support custom formats', async () => {
Expand All @@ -62,7 +66,7 @@ describe('@rdfjs/fetch', () => {
formats: customFormats
})

expect(accept).toBe('application/ld+json, text/turtle')
strictEqual(accept, 'application/ld+json, text/turtle')
})

it('should use @rdfjs/dataset as default factory', async () => {
Expand All @@ -73,7 +77,7 @@ describe('@rdfjs/fetch', () => {
const res = await rdfFetch('http://example.org/factory-default')
const dataset = await res.dataset()

expect(dataset instanceof rdf.dataset().constructor).toBe(true)
strictEqual(dataset instanceof rdf.dataset().constructor, true)
})

it('should support custom factory', async () => {
Expand All @@ -93,6 +97,6 @@ describe('@rdfjs/fetch', () => {
})
const dataset = await res.dataset()

expect(dataset instanceof CustomDataset).toBe(true)
strictEqual(dataset instanceof CustomDataset, true)
})
})