Skip to content

Commit c9a8b9c

Browse files
zivyangllpopomore
authored andcommitted
fix: hackernews-datahub remove egg-datahub (#90)
<!-- Thank you for your pull request. Please review below requirements. Bug fixes and new features should include tests and possibly benchmarks. Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md 感谢您贡献代码。请确认下列 checklist 的完成情况。 Bug 修复和新功能必须包含测试,必要时请附上性能测试。 Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md --> ##### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] `npm test` passes - [ x] tests and/or benchmarks are included - [ x] documentation is changed or added - [ x] commit message follows commit guidelines ##### Affected core subsystem(s) <!-- Provide affected core subsystem(s). --> remove `egg-datahub` from `hackernews-datahub`
1 parent b17d146 commit c9a8b9c

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

hackernews-datahub/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ $ npm run test
2424
## E2E Test
2525

2626
```bash
27+
$ npm run datahub
2728
$ npm run dev:e2e
2829
$ npm run test:e2e
2930
```

hackernews-datahub/config/config.default.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const fs = require('fs');
44
const path = require('path');
5+
const datahubConfig = require('../macaca-datahub.config');
56

67
module.exports = appInfo => {
78
const config = {};
@@ -13,7 +14,7 @@ module.exports = appInfo => {
1314
'/favicon.ico': fs.readFileSync(path.join(appInfo.baseDir, 'app/public/favicon.png')),
1415
};
1516

16-
const mockPort = 5678;
17+
const mockPort = datahubConfig.port;
1718
const hubName = 'hackernews';
1819

1920
config.news = {
@@ -31,13 +32,6 @@ module.exports = appInfo => {
3132
},
3233
};
3334

34-
// https://github.com/macacajs/macaca-datahub#configuration
35-
36-
config.datahub = {
37-
port: mockPort,
38-
store: path.resolve(__dirname, '..', 'data'),
39-
};
40-
4135
return config;
4236
};
4337

hackernews-datahub/config/plugin.js

-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@ exports.nunjucks = {
55
package: 'egg-view-nunjucks',
66
};
77

8-
exports.datahub = {
9-
enable: true,
10-
package: 'egg-datahub',
11-
};
12-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
5+
module.exports = {
6+
mode: 'local',
7+
port: 5678, // must be 5678, same with datahub-nodejs-sdk's default port
8+
store: path.resolve(__dirname, 'data'),
9+
};

hackernews-datahub/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"chai": "^4.1.2",
1818
"cross-env": "^5.1.5",
1919
"egg-bin": "^4.3.5",
20-
"egg-datahub": "2",
2120
"egg-mock": "^3.13.1",
2221
"eslint": "^4.12.0",
2322
"eslint-config-egg": "^5.1.1",
2423
"macaca-cli": "^2.1.2",
24+
"macaca-datahub": "^2.3.5",
2525
"macaca-electron": "2",
2626
"macaca-wd": "2"
2727
},
@@ -31,6 +31,7 @@
3131
"scripts": {
3232
"dev": "egg-bin dev",
3333
"test": "egg-bin test test/unittest",
34+
"datahub": "datahub server -c macaca-datahub.config.js --verbose",
3435
"dev:e2e": "cross-env NODE_ENV=test MOCK=true egg-bin dev",
3536
"test:e2e": "cross-env NODE_ENV=test macaca run --f_options '--opts test/e2e/mocha.opts' -d ./test/e2e",
3637
"cov": "egg-bin cov",

hackernews-datahub/test/e2e/datahub.test.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ describe('test/datahub.test.js', () => {
2222

2323
afterEach(function() {
2424
return driver
25+
.coverage()
2526
.saveScreenshots(this);
2627
});
2728

@@ -44,8 +45,8 @@ describe('test/datahub.test.js', () => {
4445
scene: 'default',
4546
})
4647
.getUrl(BASE_URL)
47-
.sleep(1000)
48-
.hasText('#wrapper > div.news-view.view.v-transition > div:nth-child(10) > span', '10');
48+
.elementByCss('#wrapper > div.news-view.view.v-transition > div:nth-child(10) > span')
49+
.hasText('10');
4950
});
5051

5152
it('list20 render should be ok', async function() {
@@ -56,8 +57,8 @@ describe('test/datahub.test.js', () => {
5657
scene: 'list20',
5758
})
5859
.getUrl(BASE_URL)
59-
.sleep(1000)
60-
.hasText('#wrapper > div.news-view.view.v-transition > div:nth-child(20) > span', '20');
60+
.elementByCss('#wrapper > div.news-view.view.v-transition > div:nth-child(20) > span')
61+
.hasText('20');
6162
});
6263

6364
it('list5 render should be ok', async function() {
@@ -68,8 +69,8 @@ describe('test/datahub.test.js', () => {
6869
scene: 'list5',
6970
})
7071
.getUrl(BASE_URL)
71-
.sleep(1000)
72-
.hasText('#wrapper > div.news-view.view.v-transition > div:nth-child(5) > span', '5');
72+
.elementByCss('#wrapper > div.news-view.view.v-transition > div:nth-child(5) > span')
73+
.hasText('5');
7374
});
7475

7576
it('list0 render should be empty', async function() {
@@ -80,8 +81,8 @@ describe('test/datahub.test.js', () => {
8081
scene: 'empty',
8182
})
8283
.getUrl(BASE_URL)
83-
.sleep(1000)
84-
.hasText('#wrapper > div.news-view.view.v-transition > p', 'empty');
84+
.elementByCss('#wrapper > div.news-view.view.v-transition > p')
85+
.hasText('empty');
8586
});
8687
});
8788
});

0 commit comments

Comments
 (0)