Skip to content

Commit

Permalink
Removing coffee-script and porting the fixture code to es6 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
acolchado authored Dec 4, 2016
1 parent fc57da8 commit 77d1085
Show file tree
Hide file tree
Showing 26 changed files with 141 additions and 491 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"lint": "eslint .",
"pretest": "npm run lint",
"test-unit": "babel-node --debug node_modules/mocha/bin/_mocha ./test/unit/",
"test-unit-legacy": "babel-node --debug node_modules/mocha/bin/_mocha ./test/legacy/",
"test-integration": "babel-node --debug node_modules/mocha/bin/_mocha ./test/integration/",
"test": "npm run test-unit && npm run test-unit-legacy && npm run test-integration",
"test": "npm run test-unit && npm run test-integration",
"start": "node example/start.js",
"build-and-test": "npm run build && npm test"
},
Expand Down Expand Up @@ -55,8 +54,7 @@
"express-device": "^0.3.11",
"express-winston": "^2.0.0",
"method-override": "^2.3.1",
"ejs": "^2.2.3",
"coffee-script": "^1.10.0"
"ejs": "^2.2.3"
},
"devDependencies": {
"babel-cli": "^6.5.1",
Expand Down
5 changes: 0 additions & 5 deletions test/fixtures/config/test.coffee

This file was deleted.

6 changes: 6 additions & 0 deletions test/fixtures/config/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function () {
return this.properties({
Port: 9088,
RootWebPath: '/user/agustin/test/'
});
}
8 changes: 0 additions & 8 deletions test/fixtures/controllers/MockController.coffee

This file was deleted.

12 changes: 12 additions & 0 deletions test/fixtures/controllers/MockController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function (BaseController) {

class MockController extends BaseController {
configure(app) {
super.configure(app);
app.get("/", (req, res) => { res.status(200).send("SomeIndex") });
app.get("/with-error", (req, res) => { throw new Error("Throwing a basic error") });
}
}

return new MockController();
}
26 changes: 0 additions & 26 deletions test/fixtures/controllers/PromiseMiddlewareTestController.coffee

This file was deleted.

36 changes: 36 additions & 0 deletions test/fixtures/controllers/PromiseMiddlewareTestController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = function (BaseController, Promise) {

class PromiseMiddlewareTestController extends BaseController {

configure(app) {
super.configure(app);
app.get('/promise-middleware-test--jsonasync', this.getJsonAsync);
app.get('/promise-middleware-test--renderasync', this.getRenderAsync);
app.get('/promise-middleware-test--sendAsync', this.getSendAsync);
app.get('/promise-middleware-test--sendStatusAsync', this.getSendStatusAsync);
app.get('/promise-middleware-test--formatAsync', this.getFormatAsync);
}

getJsonAsync(req, res) {
res.jsonAsync(Promise.resolve('jsonAsync success'));
}

getRenderAsync(req, res) {
res.renderAsync('renderView', Promise.resolve({ microapp: 'renderAsync success' }));
}

getSendAsync(req, res) {
res.sendAsync(Promise.resolve('sendAsync success'));
}

getSendStatusAsync(req, res) {
res.sendStatusAsync(Promise.resolve({ status: 200 }));
}

getFormatAsync(req, res) {
res.formatAsync(Promise.resolve('formatAsync success'));
}
}

return new PromiseMiddlewareTestController();
};
18 changes: 0 additions & 18 deletions test/fixtures/controllers/ServerErrorTestController.coffee

This file was deleted.

25 changes: 25 additions & 0 deletions test/fixtures/controllers/ServerErrorTestController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = function (BaseController, SpurErrors) {

class ServerErrorTestController extends BaseController {
configure(app) {
super.configure(app);
app.get('/500-error-test', this.getErrorTest.bind(this));
app.get('/500-standard-error-test', this.getStandardErrorTest.bind(this));
app.get('/404-error-test', this.getNotFoundErrorTest.bind(this));
}

getErrorTest(req, res) {
throw SpurErrors.InternalServerError.create('Some dumb server error');
}

getStandardErrorTest(req, res) {
throw 'Some dumb server error';
}

getNotFoundErrorTest() {
throw SpurErrors.NotFoundError.create('Some dumb not found error');
}
}

return new ServerErrorTestController();
};
27 changes: 0 additions & 27 deletions test/fixtures/injector.coffee

This file was deleted.

28 changes: 28 additions & 0 deletions test/fixtures/injector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const path = require('path');
const spur = require('spur-ioc');
const spurCommon = require('spur-common');
const localInjector = require('../../src/injector');
const registerConfig = require('spur-common/registerConfig');
const colors = require('colors');

module.exports = function () {

const ioc = spur.create('test-spur-web');

registerConfig(ioc, path.join(__dirname, 'config'));

ioc.merge(spurCommon());
ioc.merge(localInjector());

ioc.registerFolders(__dirname, [
'controllers/',
'middleware/',
'runtime/'
]);

ioc.registerDependencies({
colors: colors
});

return ioc;
};
7 changes: 0 additions & 7 deletions test/fixtures/middleware/TestBaseMiddleware.coffee

This file was deleted.

12 changes: 12 additions & 0 deletions test/fixtures/middleware/TestBaseMiddleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function (BaseMiddleware, Logger) {

class TestBaseMiddleware extends BaseMiddleware {

configure() {
super.configure();
Logger.log('Subclass called');
}
}

return new TestBaseMiddleware();
};
13 changes: 0 additions & 13 deletions test/fixtures/runtime/TestWebServer.coffee

This file was deleted.

19 changes: 19 additions & 0 deletions test/fixtures/runtime/TestWebServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = function (BaseWebServer, Logger, path) {

class TestWebServer extends BaseWebServer {

registerDefaultMiddleware(){
super.registerDefaultMiddleware();
this.registerEjsTemplates();
}

registerEjsTemplates() {
Logger.log('EJS Template Registration');

this.app.set('view engine', 'ejs');
this.app.set('views', path.join(__dirname, '../views'));
}
}

return new TestWebServer();
}
2 changes: 1 addition & 1 deletion test/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ global.chai = require('chai');
global.expect = global.chai.expect;

global.srcDir = path.resolve(__dirname, '../src');
global.injector = require(path.join(__dirname, 'fixtures', 'injector.coffee'));
global.injector = require(path.join(__dirname, 'fixtures', 'injector'));

process.env.NODE_ENV = 'test';

Expand Down
26 changes: 0 additions & 26 deletions test/legacy/middleware/BaseMiddlewareSpec.coffee

This file was deleted.

13 changes: 0 additions & 13 deletions test/legacy/middleware/DefaultMiddlewareSpec.coffee

This file was deleted.

Loading

0 comments on commit 77d1085

Please sign in to comment.