Skip to content

Commit 074b477

Browse files
authored
Merge pull request #2 from rdfjs-base/header-export
updated tests, export Headers
2 parents 36e729a + c31474a commit 074b477

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: node_js
22
node_js:
3-
- "8"
43
- "10"
54
- "12"

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ function rdfFetch (url, { factory = defaultFactory, formats = defaultFormats, ..
66
return rdfFetchLite(url, { factory, formats, ...options })
77
}
88

9+
rdfFetch.Headers = rdfFetchLite.Headers
10+
911
module.exports = rdfFetch

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Wrapper for fetch to simplify sending and receiving RDF data",
55
"main": "index.js",
66
"scripts": {
7-
"test": "standard && jest"
7+
"test": "standard && mocha"
88
},
99
"repository": {
1010
"type": "git",
@@ -23,12 +23,12 @@
2323
"homepage": "https://github.com/rdfjs-base/fetch",
2424
"dependencies": {
2525
"@rdfjs/dataset": "^1.0.1",
26-
"@rdfjs/fetch-lite": "^2.0.1",
26+
"@rdfjs/fetch-lite": "^2.1.0",
2727
"@rdfjs/formats-common": "^2.0.1"
2828
},
2929
"devDependencies": {
3030
"@rdfjs/sink-map": "^1.0.1",
31-
"jest": "^24.9.0",
31+
"mocha": "^7.1.1",
3232
"nock": "^11.6.0",
3333
"standard": "^14.3.1"
3434
}

test/Headers.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { strictEqual } = require('assert')
2+
const { describe, it } = require('mocha')
3+
const { Headers } = require('..')
4+
5+
describe('Headers', () => {
6+
it('should be a constructor', () => {
7+
strictEqual(typeof Headers, 'function')
8+
})
9+
10+
it('should implement the Headers interface', () => {
11+
const headers = new Headers()
12+
13+
strictEqual(typeof headers.append, 'function')
14+
strictEqual(typeof headers.delete, 'function')
15+
strictEqual(typeof headers.entries, 'function')
16+
strictEqual(typeof headers.get, 'function')
17+
strictEqual(typeof headers.has, 'function')
18+
strictEqual(typeof headers.set, 'function')
19+
})
20+
})

test/test.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
/* global describe, expect, it */
2-
1+
const { strictEqual } = require('assert')
2+
const { describe, it } = require('mocha')
33
const nock = require('nock')
44
const rdf = require('@rdfjs/dataset')
55
const rdfFetch = require('..')
66
const SinkMap = require('@rdfjs/sink-map')
77

88
describe('@rdfjs/fetch', () => {
99
it('should be a function', () => {
10-
expect(typeof rdfFetch).toBe('function')
10+
strictEqual(typeof rdfFetch, 'function')
1111
})
1212

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

16-
expect(typeof result).toBe('object')
17-
expect(typeof result.then).toBe('function')
16+
strictEqual(typeof result, 'object')
17+
strictEqual(typeof result.then, 'function')
1818
})
1919

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

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

33-
expect([
33+
const mediaTypes = [
3434
'application/ld+json',
3535
'application/trig',
3636
'application/n-quads',
3737
'application/n-triples',
3838
'text/n3',
3939
'text/turtle'
40-
].every(mediaType => accept.includes(mediaType))).toBe(true)
40+
]
41+
42+
mediaTypes.forEach(mediaType => {
43+
strictEqual(accept.includes(mediaType), true)
44+
})
4145
})
4246

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

65-
expect(accept).toBe('application/ld+json, text/turtle')
69+
strictEqual(accept, 'application/ld+json, text/turtle')
6670
})
6771

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

76-
expect(dataset instanceof rdf.dataset().constructor).toBe(true)
80+
strictEqual(dataset instanceof rdf.dataset().constructor, true)
7781
})
7882

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

96-
expect(dataset instanceof CustomDataset).toBe(true)
100+
strictEqual(dataset instanceof CustomDataset, true)
97101
})
98102
})

0 commit comments

Comments
 (0)