1

I have the code below and I need to know how I could use spyon with previousValue and currentValue in my test to coverage the conditional if (cur !== prev && cur === 100).

ngOnChanges(changes: SimpleChanges) {
    if (changes['highlightData'] && !changes['highlightData'].isFirstChange()) {
        const prev: any = changes['highlightData'].previousValue;
        const cur: any = changes['highlightData'].currentValue;

        if (cur !== prev && cur === 100) {
            this._render.setElementClass(this._elementRef.nativeElement, 'animate', true);

            setTimeout(() => {
                this._render.setElementClass(this._elementRef.nativeElement, 'animate', false);
            }, 3000);
        }
    }
}

Does anyone know how can I do that? Thanks.

Marcio M.
  • 371
  • 1
  • 6
  • 15

1 Answers1

-1

2 methods are provided in this blog, one is to manually call it and other is to use a wrapper to trigger it by framework

dhaval
  • 2,368
  • 9
  • 35
  • 60