Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 增加applicationContext中的ctx注入,支持mock ts类型定义的function #125

Merged
merged 4 commits into from Jan 28, 2019

Conversation

kurten
Copy link
Contributor

@kurten kurten commented Jan 27, 2019

  1. MidwayContainer中初始化ctx,默认注入,防止直接调用app.applicationContext.getAsync or get找不到ctx,出错
  2. midway-mock增加mockClassFunction,支持mock指定定义class的指定函数

@czy88840616

* @param ctx ctx
*/
updateContext(ctx) {
this.ctx = Object.assign({}, ctx || {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不好吧。。。updateContext 挪过来做啥的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

方便后续修改啊,mock使用

import * as assert from 'power-assert';
import { MidwayMock, MidwayMockApplication } from './src';

export {
assert
};
export declare const app: MidwayMockApplication;
export declare const mock: MidwayMock;
export declare const mm: MidwayMock;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个删了 ci 会报错的。

@codecov-io
Copy link

codecov-io commented Jan 28, 2019

Codecov Report

Merging #125 into master will increase coverage by 1.89%.
The diff coverage is 86.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
+ Coverage   77.64%   79.54%   +1.89%     
==========================================
  Files          59       61       +2     
  Lines        1991     2180     +189     
  Branches      313      351      +38     
==========================================
+ Hits         1546     1734     +188     
+ Misses        338      331       -7     
- Partials      107      115       +8
Impacted Files Coverage Δ
...ntext/src/factory/common/ManagedResolverFactory.ts 78.81% <100%> (+9.81%) ⬆️
packages/context/src/base/Resource.ts 89.47% <100%> (-0.19%) ⬇️
packages/midway-core/src/container.ts 85.07% <40%> (-0.43%) ⬇️
packages/context/src/factory/requestContainer.ts 80% <0%> (-20%) ⬇️
packages/context/src/utils/decorator.ts 84.61% <0%> (-15.39%) ⬇️
packages/context/src/annotation/inject.ts 93.1% <0%> (-6.9%) ⬇️
packages/context/src/annotation/objectDef.ts 88.37% <0%> (-0.52%) ⬇️
packages/context/src/utils/errMsg.ts 100% <0%> (ø) ⬆️
packages/context/src/utils/metaKeys.ts 100% <0%> (ø) ⬆️
packages/context/src/factory/common/constants.ts 100% <0%> (ø) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2f21b0...f564f85. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants