mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 12:43:18 +08:00
Clean
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
[](https://travis-ci.org/typicode/json-server)
|
[](https://travis-ci.org/typicode/json-server)
|
||||||
[](http://badge.fury.io/js/json-server)
|
[](http://badge.fury.io/js/json-server)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
# JSON Server
|
# JSON Server
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
// Small database to be used during tests
|
|
||||||
module.exports = function() {
|
|
||||||
var db = {};
|
|
||||||
|
|
||||||
db.posts = [
|
|
||||||
{id: 1, body: 'foo'},
|
|
||||||
{id: 2, body: 'bar'}
|
|
||||||
]
|
|
||||||
|
|
||||||
db.comments = [
|
|
||||||
{id: 1, published: true, postId: 1},
|
|
||||||
{id: 2, published: false, postId: 1},
|
|
||||||
{id: 3, published: false, postId: 2},
|
|
||||||
{id: 4, published: false, postId: 2},
|
|
||||||
]
|
|
||||||
|
|
||||||
return db;
|
|
||||||
}
|
|
@ -2,14 +2,24 @@ var request = require('supertest')
|
|||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var low = require('low')
|
var low = require('low')
|
||||||
var server = require('../src/server')
|
var server = require('../src/server')
|
||||||
var fixture = require('./fixture')
|
|
||||||
var db
|
var db
|
||||||
|
|
||||||
describe('Server', function() {
|
describe('Server', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
low.db = fixture()
|
low.db = {}
|
||||||
server
|
|
||||||
|
low.db.posts = [
|
||||||
|
{id: 1, body: 'foo'},
|
||||||
|
{id: 2, body: 'bar'}
|
||||||
|
]
|
||||||
|
|
||||||
|
low.db.comments = [
|
||||||
|
{id: 1, published: true, postId: 1},
|
||||||
|
{id: 2, published: false, postId: 1},
|
||||||
|
{id: 3, published: false, postId: 2},
|
||||||
|
{id: 4, published: false, postId: 2},
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('GET /db', function() {
|
describe('GET /db', function() {
|
||||||
@ -126,4 +136,26 @@ describe('Server', function() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Static routes', function() {
|
||||||
|
|
||||||
|
describe('GET /', function() {
|
||||||
|
it('should respond with html', function(done) {
|
||||||
|
request(server)
|
||||||
|
.get('/')
|
||||||
|
.expect('Content-Type', /html/)
|
||||||
|
.expect(200, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('GET /stylesheets/style.css', function() {
|
||||||
|
it('should respond with css', function(done) {
|
||||||
|
request(server)
|
||||||
|
.get('/stylesheets/style.css')
|
||||||
|
.expect('Content-Type', /css/)
|
||||||
|
.expect(200, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
@ -1,25 +0,0 @@
|
|||||||
var request = require('supertest')
|
|
||||||
var assert = require('assert')
|
|
||||||
var server = require('../src/server')
|
|
||||||
|
|
||||||
describe('Static routes', function() {
|
|
||||||
|
|
||||||
describe('GET /', function() {
|
|
||||||
it('should respond with html', function(done) {
|
|
||||||
request(server)
|
|
||||||
.get('/')
|
|
||||||
.expect('Content-Type', /html/)
|
|
||||||
.expect(200, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('GET /stylesheets/style.css', function() {
|
|
||||||
it('should respond with css', function(done) {
|
|
||||||
request(server)
|
|
||||||
.get('/stylesheets/style.css')
|
|
||||||
.expect('Content-Type', /css/)
|
|
||||||
.expect(200, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
Reference in New Issue
Block a user