Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure test failures #231

Merged
merged 2 commits into from
Jun 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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