Skip to content

Commit

Permalink
(#231) - Ensure test failures
Browse files Browse the repository at this point in the history
* Ensure test failure when fauxton doesn't load

* Ensure test failures fail.
  • Loading branch information
reconbot authored and garrensmith committed Jun 19, 2017
1 parent 7515730 commit 445e42e
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions tests/express-pouchdb/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,17 @@ describe('config', function () {
});
});
});
it('should support externally adding a default', function (done) {
it('should support externally adding a default', function () {
expressApp.couchConfig.registerDefault('a', 'b', 'c');
request(expressApp)
return request(expressApp)
.get('/_config')
.expect(200)
.expect(function (res) {
.then(function (res) {
var a = JSON.parse(res.text).a;
if (!(typeof a === "object" && a.b === "c")) {
return "Default not shown";
throw new Error("Default not shown");
}
})
.end(done);
});
});
it('should support externally getting a config value', function (done) {
request(expressApp)
Expand All @@ -154,21 +153,20 @@ describe('config', function () {
done();
});
});
it('should support external listeners to a config change', function (done) {
it('should support external listeners to a config change', function () {
var changed = false;
expressApp.couchConfig.on('test2.a', function () {
changed = true;
});
request(expressApp)
return request(expressApp)
.put('/_config/test2/a')
.send('"b"')
.expect(200)
.expect(function () {
.then(function () {
if (!changed) {
return "Didn't get notice of the setting change";
throw new Error("Didn't get notice of the setting change");
}
})
.end(done);
});
});
});

Expand Down Expand Up @@ -200,25 +198,24 @@ function testWelcome(app, done, path) {
request(app)
.get(path)
.expect(200)
.expect(function (res) {
.then((res) => {
if (!/Welcome!/.test(res.text)) {
return "No 'Welcome!' in response";
throw new Error("No 'Welcome!' in response");
}
})
.end(done);
.then(done, done);
}

describe('modes', function () {
it('should always return a 404 in our custom configuration', function (done) {
request(customApp)
it('should always return a 404 in our custom configuration', function () {
return request(customApp)
.get('/')
.expect(404)
.expect(function (res) {
.then(function (res) {
if (JSON.parse(res.text).error !== 'not_found') {
return "Wrong response body";
throw new Error("Wrong response body");
}
})
.end(done);
});
});
it('should generate a functioning core app', function (done) {
testWelcome(coreApp, done, '/');
Expand Down Expand Up @@ -247,16 +244,15 @@ describe('redirects', function () {
.expect(301)
.end(done);
});
it('GET /_utils/ should return fauxton', function (done) {
request(coreApp)
it('GET /_utils/ should return fauxton', function () {
return request(coreApp)
.get('/_utils/')
.expect(200)
.expect(function (res) {
if (!/<title>PouchDB Server<\/title>/.test(res.text)) {
return "No '<title>PouchDB Server</title>' in response";
.then(function (res) {
if (!/<p>Fauxton <strong>requires<\/strong> JavaScript to be enabled.<\/p>/.test(res.text)) {
throw new Error('No "<p>Fauxton <strong>requires</strong> JavaScript to be enabled.</p>" in response');
}
})
.end(done);
});
});
});

Expand Down

0 comments on commit 445e42e

Please sign in to comment.