mirror of
https://github.com/fergalmoran/dss.web.git
synced 2026-02-16 13:11:33 +00:00
Enable downloads for all
This commit is contained in:
10
server/api/thing/index.js
Normal file
10
server/api/thing/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var express = require('express');
|
||||
var controller = require('./thing.controller');
|
||||
|
||||
var router = express.Router();
|
||||
|
||||
router.get('/', controller.index);
|
||||
|
||||
module.exports = router;
|
||||
35
server/api/thing/index.spec.js
Normal file
35
server/api/thing/index.spec.js
Normal file
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
var proxyquire = require('proxyquire').noPreserveCache();
|
||||
|
||||
var thingCtrlStub = {
|
||||
index: 'thingCtrl.index'
|
||||
};
|
||||
|
||||
var routerStub = {
|
||||
get: sinon.spy()
|
||||
};
|
||||
|
||||
// require the index with our stubbed out modules
|
||||
var thingIndex = proxyquire('./index.js', {
|
||||
express: {
|
||||
Router() {
|
||||
return routerStub;
|
||||
}
|
||||
},
|
||||
'./thing.controller': thingCtrlStub
|
||||
});
|
||||
|
||||
describe('Thing API Router:', function() {
|
||||
it('should return an express router instance', function() {
|
||||
expect(thingIndex).to.equal(routerStub);
|
||||
});
|
||||
|
||||
describe('GET /api/things', function() {
|
||||
it('should route to thing.controller.index', function() {
|
||||
expect(routerStub.get
|
||||
.withArgs('/', 'thingCtrl.index')
|
||||
).to.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
});
|
||||
11
server/api/thing/thing.controller.js
Normal file
11
server/api/thing/thing.controller.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Using Rails-like standard naming convention for endpoints.
|
||||
* GET /api/things -> index
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// Gets a list of Things
|
||||
export function index(req, res) {
|
||||
res.json([]);
|
||||
}
|
||||
28
server/api/thing/thing.integration.js
Normal file
28
server/api/thing/thing.integration.js
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var app = require('../..');
|
||||
import request from 'supertest';
|
||||
|
||||
describe('Thing API:', function() {
|
||||
describe('GET /api/things', function() {
|
||||
var things;
|
||||
|
||||
beforeEach(function(done) {
|
||||
request(app)
|
||||
.get('/api/things')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /json/)
|
||||
.end((err, res) => {
|
||||
if(err) {
|
||||
return done(err);
|
||||
}
|
||||
things = res.body;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should respond with JSON array', function() {
|
||||
expect(things).to.be.instanceOf(Array);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user