-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtest.js
53 lines (38 loc) · 1.1 KB
/
test.js
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
var prerender = require('./');
var request = require('supertest');
var koa = require('koa');
var expect = require('chai').expect;
describe('Koa prerender middleware', function() {
this.timeout(5000);
it('exists', function () {
expect(prerender).to.be.ok;
});
describe('prerenders when', function() {
it('url contains _escaped_fragment_', function (done) {
var app = koa();
app.use(prerender());
request(app.listen())
.get('/?_escaped_fragment_')
.expect('X-Prerender', 'true')
.expect(200, done);
});
it('user-agent looks like a bot', function (done) {
var app = koa();
app.use(prerender());
request(app.listen())
.get('/')
.set('user-agent', 'twitterbot')
.expect('X-Prerender', 'true')
.expect(200, done);
});
it('x-bufferbot is set in options', function (done) {
var app = koa();
app.use(prerender());
request(app.listen())
.get('/')
.set('x-bufferbot', 'whatever')
.expect('X-Prerender', 'true')
.expect(200, done);
});
});
});