Merge pull request #160 from supasate/fix/ignore-copyright-in-dummy-swagger-ui-test

[Fix] `overrides-swagger-ui files` test ignores copyright in dummy file.
This commit is contained in:
Miroslav Bajtoš 2016-05-09 16:21:51 +02:00
commit 5eece0b3ae
1 changed files with 26 additions and 3 deletions

View File

@ -38,6 +38,7 @@ describe('explorer', function() {
assert(!!~res.text.indexOf('<title>StrongLoop API Explorer</title>'), assert(!!~res.text.indexOf('<title>StrongLoop API Explorer</title>'),
'text does not contain expected string'); 'text does not contain expected string');
done(); done();
}); });
}); });
@ -49,8 +50,10 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
expect(res.body).to expect(res.body).to
.have.property('url', '/explorer/swagger.json'); .have.property('url', '/explorer/swagger.json');
done(); done();
}); });
}); });
@ -71,8 +74,10 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
expect(res.body).to expect(res.body).to
.have.property('url', '/swagger/swagger.json'); .have.property('url', '/swagger/swagger.json');
done(); done();
}); });
}); });
@ -89,8 +94,10 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
expect(res.body).to expect(res.body).to
.have.property('url', '/explorer/swagger.json'); .have.property('url', '/explorer/swagger.json');
done(); done();
}); });
}); });
@ -108,9 +115,11 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
var baseUrl = res.body.basePath; var baseUrl = res.body.basePath;
var apiPath = Object.keys(res.body.paths)[0]; var apiPath = Object.keys(res.body.paths)[0];
expect(baseUrl + apiPath).to.equal('/apis/products'); expect(baseUrl + apiPath).to.equal('/apis/products');
done(); done();
}); });
}); });
@ -128,9 +137,14 @@ describe('explorer', function() {
it('overrides swagger-ui files', function(done) { it('overrides swagger-ui files', function(done) {
request(app).get('/explorer/swagger-ui.js') request(app).get('/explorer/swagger-ui.js')
.expect(200) .expect(200)
// expect the content of `dummy-swagger-ui/swagger-ui.js` .end(function(err, res) {
.expect('/* custom swagger-ui file */' + os.EOL) if (err) return done(err);
.end(done);
// expect the content of `dummy-swagger-ui/swagger-ui.js`
expect(res.text).to.contain('/* custom swagger-ui file */' + os.EOL);
done();
});
}); });
it('overrides strongloop overrides', function(done) { it('overrides strongloop overrides', function(done) {
@ -162,8 +176,10 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
expect(res.body).to expect(res.body).to
.have.property('url', '/explorer/swagger.json'); .have.property('url', '/explorer/swagger.json');
done(); done();
}); });
}); });
@ -249,9 +265,11 @@ describe('explorer', function() {
.options('/explorer/swagger.json') .options('/explorer/swagger.json')
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
var allowOrigin = res.get('Access-Control-Allow-Origin'); var allowOrigin = res.get('Access-Control-Allow-Origin');
expect(allowOrigin, 'Access-Control-Allow-Origin') expect(allowOrigin, 'Access-Control-Allow-Origin')
.to.equal(undefined); .to.equal(undefined);
done(); done();
}); });
}); });
@ -279,10 +297,12 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
var modelNames = Object.keys(res.body.definitions); var modelNames = Object.keys(res.body.definitions);
expect(modelNames).to.contain('Customer'); expect(modelNames).to.contain('Customer');
var paths = Object.keys(res.body.paths); var paths = Object.keys(res.body.paths);
expect(paths).to.have.contain('/Customers'); expect(paths).to.have.contain('/Customers');
done(); done();
}); });
}); });
@ -312,8 +332,10 @@ describe('explorer', function() {
.expect(200) .expect(200)
.end(function(err, res) { .end(function(err, res) {
if (err) return done(err); if (err) return done(err);
var paths = Object.keys(res.body.paths); var paths = Object.keys(res.body.paths);
expect(paths).to.not.contain('/products/findOne'); expect(paths).to.not.contain('/products/findOne');
done(); done();
}); });
}); });
@ -323,6 +345,7 @@ describe('explorer', function() {
return function(done) { return function(done) {
var app = this.app = loopback(); var app = this.app = loopback();
configureRestApiAndExplorer(app, explorerBase); configureRestApiAndExplorer(app, explorerBase);
done(); done();
}; };
} }