Я получил тестовый костюм с несколькими тестовыми примерами и образец Angular 2 приложения с NgRx. Я не могу пройти один контрольный пример, и я не уверен, что этот контрольный пример корректен.
Мой вопрос: метод NgRx store.dispatch
принимает строку в качестве параметра?
Если нет, тогда как этот тестовый пример может быть пройден?
Если да, можете ли вы помочь мне понять, как реализовать Action и редуктор в этом сценарии?
Тестовый случай в беде:
it('should dispatch action when dispatchAction is called', async() => {
// you need to spy on store's 'dispatch' method
store = TestBed.get(Store);
spyOn(store, 'dispatch').and.callThrough();
// if you call function dispatchAction with 'movies' paramter. expect store to dispatch action='movies'
component.dispatchAction('movies');
fixture.detectChanges();
expect(store.dispatch).toHaveBeenCalledWith('movies');
});
Способ доставки компонента:
dispatchAction($event: string) {
// ToDo: need to write this.store.dispatch('movies') . But this method will not accept string parameter.
}