forked from philipheinser/ember-lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
56 lines (47 loc) · 1.26 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
54
55
56
'use strict';
const should = require('should');
const expect = require('chai').expect;
const redis = require('redis');
const co = require('co');
const coRedis = require('co-redis');
const client = redis.createClient(
process.env.REDIS_PORT,
process.env.REDIS_HOST
);
const dbCo = coRedis(client);
process.env.NODE_ENV = 'test';
process.env.APP_NAME = 'test';
const app = require('./index').app
const request = require('co-supertest').agent(app.listen());
beforeEach(function() {
return co(function*() {
yield dbCo.set('test:current', '12345');
yield dbCo.set('test:current-content', 'Hello, World');
yield dbCo.set('test:12345', 'Hello, World');
yield dbCo.set('test:67890', 'Hello, index_key');
});
});
describe('index', function () {
it('should return 200', function (done) {
request
.get('/')
.expect(200)
.end(function (err, res) {
should.not.exist(err);
expect(res.text).to.equal('Hello, World');
done();
});
});
});
describe('index_key', function () {
it('should return 200', function (done) {
request
.get('/?index_key=67890')
.expect(200)
.end(function (err, res) {
should.not.exist(err);
expect(res.text).to.equal('Hello, index_key');
done();
});
});
});