Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
[tests] fix http server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Jun 22, 2017
1 parent db1217e commit 18e62f0
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 285 deletions.
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ process.on('uncaughtException', function(err) {
}
});

app.use(CONFIG.relativeStaticUrl, express.static('static'));
if (!CONFIG.DISABLE_SERVE_STATIC) {
// This code not compatible with 'supertest' (in e2e.js)
// Disabled for tests.
app.use(CONFIG.relativeStaticUrl, express.static('static'));
}

app.get('/', function(req, res) {
res.writeHead(302, { Location: 'http://iframely.com'});
Expand Down
1 change: 1 addition & 0 deletions config.test_with_custom_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

DEBUG: true,
RICH_LOG_ENABLED: true,
DISABLE_SERVE_STATIC: true,

baseAppUrl: "https://localhost",
port: 8080,
Expand Down
133 changes: 65 additions & 68 deletions test/custom_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,72 +38,69 @@ describe('custom plugins', function() {
});
});

// TODO: does not work with code from app.js:
// 149: app.use(CONFIG.relativeStaticUrl, express.static('static'));

//it('should use a custom plugin if defined', function(done) {
// startWithENV(ENV_WITH_CUSTOM_PLUGINS, function () {
// targetMockedServer.on({
// method: 'GET',
// path: '/testok',
// reply: {
// status: 200,
// headers: { 'content-type': 'text/html' },
// body: "<html><title>my title</title><meta name='description' content='my description'><body>Hi there!</body></html>"
// }
// });
//
// var url = TARGET_MOCKED_SERVER_BASEURL + '/testok';
// request(BASE_IFRAMELY_SERVER_URL)
// .get('/iframely?url=' + url)
// .end(function(err, res) {
// chai.expect(res.body.meta.description).to.equal('custom description for test.com domain');
// done(err);
// });
// });
//});
//
//it('should use a core plugin if no custom plugin exists', function(done) {
// startWithENV('test', function () {
// targetMockedServer.on({
// method: 'GET',
// path: '/testok',
// reply: {
// status: 200,
// headers: { 'content-type': 'text/html' },
// body: "<html><title>my title</title><meta name='description' content='my description'><body>Hi there!</body></html>"
// }
// });
//
// var url = TARGET_MOCKED_SERVER_BASEURL + '/testok';
// request(BASE_IFRAMELY_SERVER_URL)
// .get('/iframely?url=' + url)
// .end(function(err, res) {
// chai.expect(res.body.meta.title).to.equal('my title');
// done(err);
// });
// });
//});
//
//it('should use a custom plugin overriding a core plugin ', function(done) {
// startWithENV(ENV_WITH_CUSTOM_PLUGINS, function () {
// targetMockedServer.on({
// method: 'GET',
// path: '/testok',
// reply: {
// status: 200,
// headers: { 'content-type': 'text/html' },
// body: "<html><title>my title</title><meta name='description' content='my description'><body>Hi there!</body></html>"
// }
// });
//
// var url = TARGET_MOCKED_SERVER_BASEURL + '/testok';
// request(BASE_IFRAMELY_SERVER_URL)
// .get('/iframely?url=' + url)
// .end(function(err, res) {
// chai.expect(res.body.meta.title).to.equal('TITLE FROM CUSTOM-PLUGIN');
// done(err);
// });
// });
//});
it('should use a custom plugin if defined', function(done) {
startWithENV(ENV_WITH_CUSTOM_PLUGINS, function () {
targetMockedServer.on({
method: 'GET',
path: '/testok',
reply: {
status: 200,
headers: { 'content-type': 'text/html' },
body: "<html><title>my title</title><meta name='description' content='my description'><body>Hi there!</body></html>"
}
});

var url = TARGET_MOCKED_SERVER_BASEURL + '/testok';
request(BASE_IFRAMELY_SERVER_URL)
.get('/iframely?url=' + url)
.end(function(err, res) {
chai.expect(res.body.meta.description).to.equal('custom description for test.com domain');
done(err);
});
});
});

it('should use a core plugin if no custom plugin exists', function(done) {
startWithENV('test', function () {
targetMockedServer.on({
method: 'GET',
path: '/testok',
reply: {
status: 200,
headers: { 'content-type': 'text/html' },
body: "<html><title>my title</title><meta name='description' content='my description'><body>Hi there!</body></html>"
}
});

var url = TARGET_MOCKED_SERVER_BASEURL + '/testok';
request(BASE_IFRAMELY_SERVER_URL)
.get('/iframely?url=' + url)
.end(function(err, res) {
chai.expect(res.body.meta.title).to.equal('my title');
done(err);
});
});
});

it('should use a custom plugin overriding a core plugin ', function(done) {
startWithENV(ENV_WITH_CUSTOM_PLUGINS, function () {
targetMockedServer.on({
method: 'GET',
path: '/testok',
reply: {
status: 200,
headers: { 'content-type': 'text/html' },
body: "<html><title>my title</title><meta name='description' content='my description'><body>Hi there!</body></html>"
}
});

var url = TARGET_MOCKED_SERVER_BASEURL + '/testok';
request(BASE_IFRAMELY_SERVER_URL)
.get('/iframely?url=' + url)
.end(function(err, res) {
chai.expect(res.body.meta.title).to.equal('TITLE FROM CUSTOM-PLUGIN');
done(err);
});
});
});
});
Loading

0 comments on commit 18e62f0

Please sign in to comment.