diff --git a/test/00-init.js b/test/00-init.js
index dcd61957..c64fdccb 100644
--- a/test/00-init.js
+++ b/test/00-init.js
@@ -150,6 +150,12 @@ global.setLocation = async function setLocation(path) {
}
};
+global.getDocumentHTML = async function getDocumentHTML() {
+ return await evalPage(function() {
+ return document.documentElement.outerHTML;
+ });
+};
+
global.evalPage = function evalPage(fnc, ...args) {
return page.evaluate(fnc, ...args);
};
@@ -178,6 +184,10 @@ global.queryElementData = async function queryElementData(query) {
let result = await evalPage(function(query) {
let block = document.querySelector(query);
+ if (!block) {
+ return false;
+ }
+
let result = {
html : block.outerHTML,
text : block.textContent,
@@ -352,7 +362,7 @@ describe('Alchemy', function() {
it('should start the server', function(done) {
alchemy.setSetting('network.port', 3470);
- alchemy.setSetting('network.postpone_requests_on_overload', false);
+ alchemy.setSetting('performance.postpone_requests_on_overload', false);
STAGES.getStage('datasource').addPostTask(() => {
Datasource.create('mongo', 'default', {uri: mongo_uri});
diff --git a/test/03-model.js b/test/03-model.js
index 114d5b76..17bb1fe6 100644
--- a/test/03-model.js
+++ b/test/03-model.js
@@ -844,7 +844,7 @@ describe('Model', function() {
doc.number = 3;
await doc.save();
- assert.strictEqual(doc.initials, undefined);
+ assert.strictEqual(doc.initials, null);
doc.initials = 'RVG';
await doc.save();
diff --git a/test/04-field.js b/test/04-field.js
index 40a5f928..9dff00b5 100644
--- a/test/04-field.js
+++ b/test/04-field.js
@@ -676,8 +676,8 @@ describe('Field.Decimal', function() {
let DecimalTester,
DecimalInSubSchema;
- before(function(next) {
- next = Function.regulate(next);
+ before(function(done) {
+ done = Function.regulate(done);
DecimalTester = Function.inherits('Alchemy.Model', 'DecimalTester');
DecimalInSubSchema = Function.inherits('Alchemy.Model', 'DecimalInSubSchema');
@@ -690,7 +690,7 @@ describe('Field.Decimal', function() {
next();
});
- }, function secondModel(next) {
+ }, async function secondModel(next) {
DecimalInSubSchema.constitute(function addFields() {
this.addField('name', 'String');
@@ -702,8 +702,7 @@ describe('Field.Decimal', function() {
this.addField('decimals', schema, {is_array: true});
next();
});
-
- }, next);
+ }, done);
});
it('should store decimal fields in the database', async function() {
diff --git a/test/05-criteria.js b/test/05-criteria.js
index 010b284e..8441043e 100644
--- a/test/05-criteria.js
+++ b/test/05-criteria.js
@@ -2,7 +2,7 @@ var assert = require('assert'),
Person;
function makeCriteria() {
- return new Classes.Alchemy.Criteria();
+ return new Classes.Alchemy.Criteria.Model();
}
describe('Criteria', function() {
@@ -26,9 +26,9 @@ describe('Criteria', function() {
assert.strictEqual(!!record._id, true, 'The _id should always be selected');
assert.strictEqual(typeof record.firstname, 'string');
- assert.strictEqual(typeof record.lastname, 'undefined');
- assert.strictEqual(typeof record.birthdate, 'undefined');
- assert.strictEqual(typeof record.male, 'undefined');
+ assert.strictEqual(record.lastname, null);
+ assert.strictEqual(record.birthdate, null);
+ assert.strictEqual(record.male, null);
assert.strictEqual(typeof record.Parent, 'undefined');
assert.strictEqual(typeof records[1].Parent, 'undefined');
});
@@ -72,7 +72,7 @@ describe('Criteria', function() {
assert.strictEqual(!!record.Parent, true, 'The Parent record wasn\'t selected');
assert.strictEqual(!!record.Parent._id, true, 'The Parent should have an _id field');
assert.strictEqual(record.Parent.firstname, 'Griet', 'The wrong record was selected as Parent');
- assert.strictEqual(typeof record.Parent.lastname, 'undefined', 'The parent record should only have an _id and firstname field');
+ assert.strictEqual(record.Parent.lastname, null, 'The parent record should only have an _id and firstname field');
});
});
diff --git a/test/06-document.js b/test/06-document.js
index 3cf0b9ea..1b662b86 100644
--- a/test/06-document.js
+++ b/test/06-document.js
@@ -123,8 +123,8 @@ describe('Document', function() {
assert.strictEqual(child.firstname, 'Jelle');
assert.strictEqual(child.lastname, 'De Loecker');
- assert.strictEqual(child.male, undefined);
- assert.deepStrictEqual(child.nicknames, undefined);
+ assert.strictEqual(child.male, null);
+ assert.deepStrictEqual(child.nicknames, []);
let jelle = await Model.get('Person').findByValues({firstname: 'Jelle'});
@@ -144,7 +144,7 @@ describe('Document', function() {
await clone.populate(['Parent.firstname', 'Parent.male']);
assert.strictEqual(clone.Parent.firstname, 'Griet');
- assert.strictEqual(clone.Parent.lastname, undefined);
+ assert.strictEqual(clone.Parent.lastname, null);
assert.strictEqual(clone.Parent.male, false);
});
});
diff --git a/test/25-controller.js b/test/25-controller.js
index 45235669..e666fa1a 100644
--- a/test/25-controller.js
+++ b/test/25-controller.js
@@ -220,11 +220,14 @@ describe('Controller', function() {
});
describe('#beforeAction(name)', function() {
- it('should be called before an action is called', async function() {
- let last_called,
- calls = 0,
- pledge = new Blast.Classes.Pledge();
+ let last_called,
+ calls = 0,
+ pledge;
+
+ it('should be called before an action is called (direct)', async function() {
+
+ pledge = new Blast.Classes.Pledge();
PersonController.setMethod(function beforeAction(name) {
last_called = name;
@@ -238,14 +241,16 @@ describe('Controller', function() {
assert.strictEqual(last_called, 'rendertest');
assert.strictEqual(calls, 1);
+ });
- result = await openHeUrl('/render_test?view=body');
+ it('should be called before an action is called (ajax)', async function() {
+
+ let result = await openHeUrl('/render_test?view=body');
assert.strictEqual(result.location, '/render_test');
assert.strictEqual(last_called, 'rendertest');
assert.strictEqual(calls, 2);
-
});
});
});
\ No newline at end of file
diff --git a/test/26-conduit.js b/test/26-conduit.js
index 40e3a913..9963ad29 100644
--- a/test/26-conduit.js
+++ b/test/26-conduit.js
@@ -10,8 +10,8 @@ describe('Controller', function() {
});
describe('#body', function() {
- it('should parse the body of any encoding type', async function() {
+ before(() => {
Router.add({
name : 'ConduitTest#bodyTest',
paths : '/conduit/body_test',
@@ -49,13 +49,20 @@ describe('Controller', function() {
this.render('static/conduit_body_test');
});
+ });
+ it('should parse the body of a url-encoded form', async function() {
post_pledge = new Pledge();
await testFormSubmission(post_pledge, 'application/x-www-form-urlencoded');
+ });
+
+ it('should parse the body of a multipart form', async function() {
post_pledge = new Pledge();
await testFormSubmission(post_pledge, 'multipart/form-data');
+ });
+ it('should parse the body of a json-encoded form', async function() {
post_pledge = new Pledge();
await testFormSubmission(post_pledge, 'json');
});
@@ -116,6 +123,9 @@ async function testFormSubmission(post_pledge, enctype) {
// Use Puppeteer for normal form submissions
await setLocation(actual_url);
+ let html = await getDocumentHTML();
+ console.log(html)
+
await queryElementData('.form-wrapper');
await setElementValueOrThrow('#firstname', 'Jelle');
diff --git a/test/40-helpers.js b/test/40-helpers.js
index b0cb11d7..2e3681b3 100644
--- a/test/40-helpers.js
+++ b/test/40-helpers.js
@@ -185,8 +185,12 @@ describe('Helper.Router', function() {
return next(err);
}
- assert.strictEqual(res, ``);
- done();
+ try {
+ assert.strictEqual(res, ``);
+ done();
+ } catch (err) {
+ done(err);
+ }
});
});
});