forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformats.js
More file actions
67 lines (61 loc) · 2.62 KB
/
formats.js
File metadata and controls
67 lines (61 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*jslint node: true*/
var supertest = require('supertest');
var path = require('path');
var fs = require('fs');
var S = require('string');
var ldnode = require('../index');
describe('formats', function () {
var ldp = ldnode.createServer({
root: __dirname + '/resources',
});
var server = supertest(ldp);
describe('HTML', function() {
it('Should return HTML containing "Hello, World!" if Accept is set to text/html', function(done) {
server.get('/hello.html')
.set('accept', 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5')
.expect('Content-type', /text\/html/)
.expect(/Hello, world!/)
.expect(200, done);
});
});
describe('JSON-LD', function() {
var isValidJSON = function(res) {
var json = JSON.parse(res.text);
};
it('Should return JSON-LD document if Accept is set to application/ld+json', function(done) {
server.get('/patch-5-initial.ttl')
.set('accept', 'application/ld+json;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5')
.expect('content-type', /application\/ld\+json/)
.expect(200, done);
});
it('Should return valid JSON if Accept is set to JSON-LD', function(done) {
server.get('/patch-5-initial.ttl')
.set('accept', 'application/ld+json;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5')
.expect(isValidJSON)
.expect(200, done);
});
});
describe('N-Quads', function() {
it('Should return N-Quads document is Accept is set to application/n-quads', function(done) {
server.get('/patch-5-initial.ttl')
.set('accept', 'application/n-quads;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5')
.expect('content-type', /application\/n-quads/)
.expect(200, done);
});
});
describe('n3', function() {
it('Should return turtle document if Accept is set to text/n3', function(done) {
server.get('/patch-5-initial.ttl')
.set('accept', 'text/n3;q=0.9,text/turtle;q=0.8,text/plain;q=0.7,*/*;q=0.5')
.expect('content-type', /text\/n3/)
.expect(200, done);
});
});
describe('none', function() {
it('Should return turtle document if no Accept header is set', function(done) {
server.get('/patch-5-initial.ttl')
.expect('content-type', /text\/turtle/)
.expect(200, done);
});
});
});