fixe bitte die tests und antworte auf deutsch

<div class="jasmine-spec-detail jasmine-failed"><div class="jasmine-description"><a href="/context.html?spec=TimeoutService">TimeoutService</a> &gt; <a href="/context.html?spec=TimeoutService%20initTimeout">initTimeout</a> &gt; <a title="should start the timeout" href="/context.html?spec=TimeoutService%20initTimeout%20should%20start%20the%20timeout">should start the timeout</a></div><div class="jasmine-messages"><div class="jasmine-result-message">Error: &lt;spyOn&gt; : resetState() method does not exist
Usage: spyOn(&lt;object&gt;, &lt;methodName&gt;)</div><div class="jasmine-stack-trace">    at &lt;Jasmine&gt;
    at UserContext.apply (http://localhost:9876/_karma_webpack_/webpack:/src/app/timeout/timeout.service.spec.ts:28:7)
    at _ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone.js:375:26)
    at ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:287:39)
    at _ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone.js:374:52)
    at Zone.run (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone.js:134:43)
    at runInTestZone (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:582:34)
    at UserContext.&lt;anonymous&gt; (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/fesm2015/zone-testing.js:597:20)</div></div></div>

import { TimeoutService } from './timeout.service';


describe('TimeoutService', () => {
  let service: TimeoutService;
  let resetStateSpy: jasmine.SpyObj<any>;

  beforeEach(() => {
    resetStateSpy = jasmine.createSpyObj('appStateResetService', ['resetState']);
    service = new TimeoutService();
  });

  afterEach(() => {
    service.unsubscribeActivity();
  });

  it('should create the service', () => {
    expect(service).toBeTruthy();
  });

  describe('initTimeout', () => {
    let resetStateSpy: jasmine.SpyObj<any>;
    beforeEach(() => {
      resetStateSpy = jasmine.createSpyObj('appStateResetService', ['resetState']);
    });
    it('should start the timeout', () => {
      spyOn(console, 'log');
      spyOn(service as any, 'resetState');
      spyOn(service as any, 'setActive');


      expect(console.log).toHaveBeenCalledWith('Timer: 50s');
      expect((service as any).resetState).toHaveBeenCalled();
      expect((service as any).setActive.calls.argsFor(0)[0]).toBeTrue();
      expect((service as any).setActive.calls.argsFor(1)[0]).toBeFalse();
    });
  });

  describe('unsubscribeActivity', () => {
    it('should unsubscribe the activity subscription', () => {
      const unsubscribeSpy = spyOn((service as any)['activitySubscription'], 'unsubscribe');

      service.unsubscribeActivity();

      expect(unsubscribeSpy).toHaveBeenCalled();
    });
  });
});

import { Injectable } from '@angular/core';
import { Subscription, fromEvent, merge, timer } from 'rxjs';
import { debounceTime, map, take, takeUntil, tap } from 'rxjs/operators';


@Injectable({
  providedIn: 'root'
})
export class TimeoutService {
  private activitySubscription: Subscription | undefined;
  constructor() {}

  initTimeout(
    timeoutDuration: number = 50,
    appStateResetService: any,
    setActive: (active: boolean) => void
  ): Subscription {
    const click$ = fromEvent(document, 'click');
    const mouseMove$ = fromEvent(document, 'mousemove');
    const touchStart$ = fromEvent(document, 'touchstart');
    const touchMove$ = fromEvent(document, 'touchmove');
    const activity$ = merge(mouseMove$, click$, touchMove$, touchStart$);

    let timeoutSubscription: Subscription | undefined;
    const resetTimeout = () => {
      setActive(false);
      if (timeoutSubscription) {
        timeoutSubscription.unsubscribe();
      }
      timeoutSubscription = timer(0, 1000)
        .pipe(
          takeUntil(activity$),
          take(timeoutDuration + 1),
          map(time => timeoutDuration - time),
          tap(time => {
            // Todo: Nach der Abnahme entfernen
            console.log(`Timer: ${time}s`);
            if (time === 0) {
              appStateResetService.resetState();
            }
          })
        )
        .subscribe({
          complete: () => {
            setActive(false);
          }
        });
    };

    setActive(true);
    resetTimeout();

    this.activitySubscription = activity$
      .pipe(
        debounceTime(1000),
        tap(() => resetTimeout())
      )
      //Todo: Console.Log nach der Abnahme entfernen
      .subscribe(() => console.log('click'));

    return this.activitySubscription;
  }
  unsubscribeActivity(): void {
    if (this.activitySubscription) {
      this.activitySubscription.unsubscribe();
    }
  }
}