Closed
Description
Posting this here, as well as in the old repo
This is a...
- feature request
- bug report
- usage question
What toolchain are you using for transpilation/bundling?
- @angular/cli
- Custom @ngTools/webpack
- Raw
ngc
- SystemJS
- Rollup
- Other
Environment
NodeJS Version: 8.11.2
Typescript Version: 2.7.2
Angular Version: 6.0.9
@angular-redux/store version: 9.0.0
@angular/cli version: (if applicable)
Description
I've read through the unit test examples, and believe that I have my set up correct. However, it seems like my mock instance is not being substituted for the real NgRedux
that is injected.
Simplified Code
Component
export class MyComponent implements OnInit {
state: ApplicationState;
constructor(private ngRedux: NgRedux<ApplicationState>) {}
ngOnInit() {
this.state = this.ngRedux.getState();
}
}
Unit Test
// In the main describe...
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ NgReduxTestingModule ],
declarations: [ MyComponent ],
schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents();
MockNgRedux.reset();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should set the initial state object', () => {
const spy = spyOn(MockNgRedux.mockInstance, 'getState');
expect(spy).toHaveBeenCalled();
});
Error Message
When I run my tests with the code above, I get the message:
Expected spy getState to have been called.
Am I missing something in my set up?