Skip to content

Commit

Permalink
test: make sure old style lifecycle is work (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored Jul 27, 2020
1 parent cf0e10d commit 4dfa3ef
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/fixtures/example/config/plugin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
'use strict';

const path = require('path');

exports.static = false;

exports.test = {
path: path.join(__dirname, '../../test-plugin'),
};
9 changes: 9 additions & 0 deletions test/fixtures/test-plugin/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

// old style without lifecycle
module.exports = app => {
app.test = {
foo: app.config.foo,
sub: app.config.sub,
};
};
6 changes: 6 additions & 0 deletions test/fixtures/test-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "test-plugin",
"eggPlugin": {
"name": "test"
}
}
10 changes: 10 additions & 0 deletions test/remote-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@ describe('test/remote-config.test.js', () => {
// for win
await sleep('1s');
asserFile.fail(path.join(app.config.rundir, 'remote_config.json'));

// make sure test-plugin is load before remote-config
const plugins = app.loader.orderPlugins.map(it => it.name);
const testIndex = plugins.indexOf('test');
const remoteIndex = plugins.indexOf('remoteConfig');
assert(testIndex < remoteIndex && testIndex !== -1 && remoteIndex !== -1);

// then check test-plugin use the newest config from remote-config
assert(app.test.foo === 'egg-remote-config');
assert(app.test.sub.a === 'b');
});
});

0 comments on commit 4dfa3ef

Please sign in to comment.