Open jessesanders opened 7 years ago
I can get the tests to work if I create a mock for the Idle class:
@Injectable()
export class IdleMock {
private onIdleEnd = new EventEmitter();
private onIdleStart = new EventEmitter();
private onTimeout = new EventEmitter();
private onTimeoutWarning = new EventEmitter();
watch() {
}
setIdle() {
}
setTimeout() {
}
setInterrupts() {
}
}
and then override the Idle class with the mock:
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
NgIdleKeepaliveModule.forRoot()
],
providers: [
{provide: Idle, useClass: IdleMock}
]
}).compileComponents();
Hi, It would be helpful if you can share the complete test file with some tests written
I'm submitting a ... (check one with "x")
Current behavior
Following the example code at https://hackedbychinese.github.io/ng2-idle. When I run the tests, they timeout with this error:
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
If I remove the call to this.idle.watch(), the tests don't timeout.
Expected behavior The tests should run and pass without timing out.
Minimal reproduction of the problem with instructions I create a new project with angular-cli (RC2), add the example code, validate the example works in the UI, run the tests using ng test, the tests now fail with a timeout.
What is the motivation / use case for changing the behavior? It would be nice to get the tests to work.
Please tell us about your environment: MAC Sierra
@ng-idle version: 2.x 2.0.0-beta.8
Angular version: 2.x 2.4
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Chrome
Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript
Node:
node --version
= 6.9.4