mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
test: add doc test (#989)
This commit is contained in:
parent
c6eb7b2f59
commit
057bc47e4c
@ -39,7 +39,7 @@ Advanced:
|
||||
Cluster Client: /advanced/cluster-client.html
|
||||
View Plugin: /advanced/view-plugin.html
|
||||
Community:
|
||||
Plugin List: /plugins
|
||||
Plugin List: /plugins/
|
||||
Contributing: /contributing.html
|
||||
Resource: /resource.html
|
||||
# Member Guide: /member_guide.html
|
||||
|
||||
@ -189,13 +189,18 @@ class Application extends EggApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* The helper class, `app/helper` will be loaded to it's prototype,
|
||||
* then you can use all method on `ctx.helper`
|
||||
* reference to {@link Helper}
|
||||
* @member {Helper} Application#Helper
|
||||
*/
|
||||
get Helper() {
|
||||
if (!this[HELPER]) {
|
||||
this[HELPER] = class Helper extends this.BaseContextClass {};
|
||||
/**
|
||||
* The Helper class which can be used as utility function.
|
||||
* Files from `${baseDir}/app/helper` will be loaded to the prototype of Helper,
|
||||
* then you can use all method on `ctx.helper` that is a instance of Helper.
|
||||
*/
|
||||
class Helper extends this.BaseContextClass {}
|
||||
this[HELPER] = Helper;
|
||||
}
|
||||
return this[HELPER];
|
||||
}
|
||||
|
||||
@ -5,6 +5,9 @@ const is = require('is-type-of');
|
||||
const sendmessage = require('sendmessage');
|
||||
const EventEmitter = require('events');
|
||||
|
||||
/**
|
||||
* Communication between app worker and agent worker by IPC channel
|
||||
*/
|
||||
class Messenger extends EventEmitter {
|
||||
|
||||
constructor() {
|
||||
|
||||
@ -58,8 +58,10 @@
|
||||
"egg-view-nunjucks": "^2.1.2",
|
||||
"eslint": "^3.19.0",
|
||||
"eslint-config-egg": "^4.2.0",
|
||||
"findlinks": "^1.1.0",
|
||||
"formstream": "^1.1.0",
|
||||
"glob": "^7.1.2",
|
||||
"koa-static": "^3.0.0",
|
||||
"mz-modules": "^1.0.0",
|
||||
"pedding": "^1.1.0",
|
||||
"spy": "^1.0.0",
|
||||
|
||||
30
test/doc.test.js
Normal file
30
test/doc.test.js
Normal file
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const findlinks = require('findlinks');
|
||||
const assert = require('assert');
|
||||
const runscript = require('runscript');
|
||||
const utils = require('./utils');
|
||||
|
||||
describe('test/doc.test.js', () => {
|
||||
|
||||
if (process.platform === 'win32') return;
|
||||
|
||||
let app;
|
||||
before(function* () {
|
||||
yield runscript('doctools build', { cwd: path.dirname(__dirname) });
|
||||
});
|
||||
before(function* () {
|
||||
app = utils.cluster({
|
||||
baseDir: 'apps/docapp',
|
||||
});
|
||||
app.coverage(false);
|
||||
yield app.ready();
|
||||
});
|
||||
after(() => app.close());
|
||||
|
||||
it('should no broken url', function* () {
|
||||
const result = yield findlinks({ src: app.url, logger: console });
|
||||
assert(result.fail === 0);
|
||||
});
|
||||
});
|
||||
7
test/fixtures/apps/docapp/app/middleware/koastatic.js
vendored
Normal file
7
test/fixtures/apps/docapp/app/middleware/koastatic.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = () => {
|
||||
return require('koa-static')(path.join(process.cwd(), 'run/doctools/public'));
|
||||
};
|
||||
8
test/fixtures/apps/docapp/config/config.default.js
vendored
Normal file
8
test/fixtures/apps/docapp/config/config.default.js
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
keys: 'test key',
|
||||
middleware: [ 'koastatic' ],
|
||||
};
|
||||
3
test/fixtures/apps/docapp/package.json
vendored
Normal file
3
test/fixtures/apps/docapp/package.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "docapp"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user