Skip to content

Commit

Permalink
update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
killmenot committed Nov 28, 2017
1 parent 97dd38f commit a4d9f8a
Show file tree
Hide file tree
Showing 35 changed files with 786 additions and 121 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ before_install:
source ~/.profile;
fi
env:
# Can't figure out how to DRY this up: http://stackoverflow.com/q/22397300/3191
- WEB_SERVER=express DATABASE=redis
- WEB_SERVER=koa DATABASE=redis
- WEB_SERVER=express DATABASE=gtm
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"dependencies": {
"body-parser": "^1.18.2",
"debug": "^3.1.0",
"ewd-client": "^1.17.0",
"ewd-qoper8": "^3.16.0",
"ewd-qoper8-cache": "^2.2.1",
Expand All @@ -67,9 +68,9 @@
"devDependencies": {
"async": "^2.6.0",
"coveralls": "^3.0.0",
"dotenv": "^4.0.0",
"eslint": "^4.9.0",
"ewd-mock": "^1.0.0",
"ewd-helloworld-service": "^1.0.0",
"ewd-mock": "^1.0.2",
"is-async-supported": "^1.2.0",
"is-jwt": "^1.0.0",
"is-uuid": "^1.0.2",
Expand Down
4 changes: 1 addition & 3 deletions spec/integration/basic/handlers/test-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ module.exports = {

handlers: {
test: function (messageObj, session, send, finished) {
const incomingText = messageObj.params.text;

finished({
text: `You sent: ${incomingText} via express`
text: `You sent: ${messageObj.params.text}`
});
}
}
Expand Down
35 changes: 17 additions & 18 deletions spec/integration/basic/testrunner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

const request = require('supertest')('http://localhost:8080');
const io = require('socket.io-client');
const isUUID = require('is-uuid');
const utils = require('../utils');

describe('integration/qewd/basic-express:', () => {
describe('integration/qewd/basic:', () => {
let cp;

const options = {
Expand All @@ -20,7 +19,7 @@ describe('integration/qewd/basic-express:', () => {
utils.exit(cp, done);
});

it('should return correct html markup', (done) => {
it('should return correct html', (done) => {
request
.get('/test-app')
.redirects(2)
Expand All @@ -30,7 +29,7 @@ describe('integration/qewd/basic-express:', () => {
.end(err => err ? done.fail(err) : done());
});

describe('register', () => {
describe('ewd-register', () => {
let data;

beforeEach(() => {
Expand All @@ -40,7 +39,7 @@ describe('integration/qewd/basic-express:', () => {
};
});

it('should be able to register app using websockets', (done) => {
it('should register app using websockets', (done) => {
const socket = io.connect('ws://localhost:8080');

socket.on('connect', () => socket.emit('ewdjs', data));
Expand All @@ -55,25 +54,25 @@ describe('integration/qewd/basic-express:', () => {
},
responseTime: jasmine.stringMatching(/^\d*ms$/)
});
expect(isUUID.v4(responseObj.message.token)).toBeTruthy();
expect(utils.isUUID(responseObj.message.token)).toBeTruthy();

done();
});
});

it('should be able to register app using ajax', (done) => {
it('should register app using ajax', (done) => {
request.
post('/ajax').
send(data).
expect(200).
expect(res => {
expect(isUUID.v4(res.body.token)).toBeTruthy();
expect(utils.isUUID(res.body.token)).toBeTruthy();
}).
end(err => err ? done.fail(err) : done());
});
});

describe('reregister', () => {
describe('ewd-reregister', () => {
let data;

beforeEach((done) => {
Expand All @@ -95,7 +94,7 @@ describe('integration/qewd/basic-express:', () => {
});
});

it('should be able to reregister app using websockets', (done) => {
it('should reregister app using websockets', (done) => {
const socket = io.connect('ws://localhost:8080');

socket.on('connect', () => socket.emit('ewdjs', data));
Expand All @@ -115,7 +114,7 @@ describe('integration/qewd/basic-express:', () => {
});
});

it('should be able to reregister app using ajax', (done) => {
it('should reregister app using ajax', (done) => {
request.
post('/ajax').
send(data).
Expand Down Expand Up @@ -154,7 +153,7 @@ describe('integration/qewd/basic-express:', () => {
});
});

it('should be able to send message using websockets', (done) => {
it('should send message using websockets', (done) => {
const socket = io.connect('ws://localhost:8080');

socket.on('connect', () => socket.emit('ewdjs', data));
Expand All @@ -165,7 +164,7 @@ describe('integration/qewd/basic-express:', () => {
type: 'test',
finished: true,
message: {
text: 'You sent: Hello world via express'
text: 'You sent: Hello world'
},
responseTime: jasmine.stringMatching(/^\d*ms$/)
});
Expand All @@ -174,21 +173,21 @@ describe('integration/qewd/basic-express:', () => {
});
});

it('should be able to send message using ajax', (done) => {
it('should send message using ajax', (done) => {
request.
post('/ajax').
send(data).
expect(200).
expect(res => {
expect(res.body).toEqual({
text: 'You sent: Hello world via express'
text: 'You sent: Hello world'
});
}).
end(err => err ? done.fail(err) : done());
});
});

describe('no type handler error', () => {
describe('no type handler', () => {
let data;

beforeEach((done) => {
Expand All @@ -210,7 +209,7 @@ describe('integration/qewd/basic-express:', () => {
});
});

it('should be able to return error message using websockets', (done) => {
it('should return error message using websockets', (done) => {
const socket = io.connect('ws://localhost:8080');

socket.on('connect', () => socket.emit('ewdjs', data));
Expand All @@ -230,7 +229,7 @@ describe('integration/qewd/basic-express:', () => {
});
});

it('should be able to return error message using ajax', (done) => {
it('should return error message using ajax', (done) => {
request.
post('/ajax').
send(data).
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/cors/testrunner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const request = require('supertest')('http://localhost:8080');
const utils = require('../utils');

describe('integration/qewd/cors-express:', () => {
describe('integration/qewd/cors:', () => {
let cp;

const options = {
Expand All @@ -18,7 +18,7 @@ describe('integration/qewd/cors-express:', () => {
utils.exit(cp, done);
});

it('should be able to expose CORS headers', (done) => {
it('should expose CORS headers', (done) => {
request.
get('/').
expect(200).
Expand Down
7 changes: 7 additions & 0 deletions spec/integration/fragments/handlers/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
servicesAllowed: {
'ewd-mock': true
}
};
31 changes: 31 additions & 0 deletions spec/integration/fragments/qewd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

const qewd = require('qewd').master;
const path = require('path');
const utils = require('../utils');

const xp = qewd.intercept();
const q = xp.q;

q.on('start', function () {
this.worker.loaderFilePath = path.join(__dirname, '../../..', 'node_modules/ewd-qoper8-worker.js');
});

q.on('started', function () {
process.send({
type: 'qewd:started'
});
});

const config = {
managementPassword: 'keepThisSecret!',
serverName: 'New QEWD Server',
webServer: utils.webServer(),
port: 8080,
poolSize: 2,
database: utils.db(),
moduleMap: {
'demo': path.join(__dirname, 'handlers/demo')
}
};
qewd.start(config);
Loading

0 comments on commit a4d9f8a

Please sign in to comment.