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

effects.test.js中的take测试中,'addDelay/@@end'这个action pattern是干嘛的?现在的npm test会出错 #1730

Closed
jibuji opened this issue May 31, 2018 · 2 comments

Comments

@jibuji
Copy link

jibuji commented May 31, 2018

Code to reproduce the issue: (请提供可复现的代码或者步骤)

it('take', done => {
    const app = create();
    app.model({
      namespace: 'count',
      state: 0,
      reducers: {
        add(state, { payload }) {
          return state + payload || 1;
        },
      },
      effects: {
        *addDelay({ payload }, { put, call }) {
          yield call(delay, payload.delay || 100);
          yield put({ type: 'add', payload: payload.amount });
        },
        *test(action, { put, select, take }) {
          yield put({ type: 'addDelay', payload: { amount: 2 } });
          ** yield take('addDelay/@@end'); **
          const count = yield select(state => state.count);
          yield put({ type: 'addDelay', payload: { amount: count, delay: 0 } });
        },
      },
    });
    app.start();
    app._store.dispatch({ type: 'count/test' });
    setTimeout(() => {
      expect(app._store.getState().count).toEqual(4);
      done();
    }, 300);
  });

上面是一段来自dva/packages/dva-core/test/effects.test.js的代码,里面的yield take('addDelay/@@end');是干嘛的?'addDelay/@@EnD'这种action pattern有什么特殊的含义吗?
我没看懂,请赐教。

Expected behavior: (预期的正常效果)

npm test应该通过

Actual behavior: (实际效果)

npm test 提示错误Cannot find module 'redux' from 'index.js'

Versions of packages used: (哪个库的哪个版本出现的问题)

on master branch commit id: b01c9a6

@ishenli
Copy link

ishenli commented Jun 11, 2018

@jibuji 看下dva2.0的发布日志:sorrycc/blog#48

@jibuji
Copy link
Author

jibuji commented Jun 20, 2018

@ishenli, I see, Thank you!

@jibuji jibuji closed this as completed Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants