mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
Merge branch 'master' of https://github.com/marko-js/marko into dist-dir
This commit is contained in:
commit
37d1d7fab9
@ -146,7 +146,7 @@
|
||||
]
|
||||
},
|
||||
"homepage": "http://markojs.com/",
|
||||
"version": "4.3.0",
|
||||
"version": "4.3.1",
|
||||
"logo": {
|
||||
"url": "https://raw.githubusercontent.com/marko-js/branding/master/marko-logo-small.png"
|
||||
}
|
||||
|
||||
@ -44,6 +44,6 @@ function patchResponse(response) {
|
||||
|
||||
res.set({ 'content-type': 'text/html; charset=utf-8' });
|
||||
|
||||
template.render(data, res);
|
||||
return template.render(data, res);
|
||||
};
|
||||
}
|
||||
|
||||
1
test/autotests/express/return-promise/template.marko
Normal file
1
test/autotests/express/return-promise/template.marko
Normal file
@ -0,0 +1 @@
|
||||
<div></div>
|
||||
28
test/autotests/express/return-promise/test.js
Normal file
28
test/autotests/express/return-promise/test.js
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
let fulfilled = false;
|
||||
|
||||
exports.createApp = function(express, markoExpressPath) {
|
||||
var app = express();
|
||||
var markoExpress = require(markoExpressPath);
|
||||
|
||||
app.use(markoExpress());
|
||||
return app;
|
||||
};
|
||||
|
||||
exports.createController = function(template) {
|
||||
return function(req, res) {
|
||||
return res.marko(template)
|
||||
.then(() => {
|
||||
fulfilled = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error fulfilling res.marko: ', err);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
exports.checkResponse = function(response, expect, helpers) {
|
||||
expect(fulfilled).to.equal(true);
|
||||
expect(response.body).to.equal('<div></div>');
|
||||
};
|
||||
@ -3,6 +3,7 @@ require('./util/test-init');
|
||||
|
||||
var chai = require('chai');
|
||||
chai.config.includeStack = true;
|
||||
const expect = chai.expect;
|
||||
var path = require('path');
|
||||
var marko = require('marko');
|
||||
var autotest = require('./autotest');
|
||||
@ -25,12 +26,12 @@ describe('express', function() {
|
||||
|
||||
require(markoExpressPath);
|
||||
|
||||
chai.expect(express.response.marko).to.equal(fn);
|
||||
expect(express.response.marko).to.equal(fn);
|
||||
});
|
||||
it('should be able to register for multiple express instances', function() {
|
||||
// test res.marko is added to the real express response
|
||||
require(markoExpressPath);
|
||||
chai.expect(express.response.marko).to.be.a('function');
|
||||
expect(express.response.marko).to.be.a('function');
|
||||
|
||||
// set up an express mock object and hijack require
|
||||
var expressMock = { response:{} };
|
||||
@ -43,7 +44,7 @@ describe('express', function() {
|
||||
|
||||
// check that res.marko is added to the mocked express response
|
||||
require(markoExpressPath);
|
||||
chai.expect(expressMock.response.marko).to.be.a('function');
|
||||
expect(expressMock.response.marko).to.be.a('function');
|
||||
|
||||
// return require to its original state
|
||||
module.require = _require;
|
||||
@ -102,7 +103,7 @@ describe('express', function() {
|
||||
if(main.checkResponse) {
|
||||
response.body = body;
|
||||
response.error = error;
|
||||
main.checkResponse(response, chai.expect, helpers);
|
||||
main.checkResponse(response, expect, helpers);
|
||||
} else {
|
||||
if(error) {
|
||||
return done(error);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user