Strona głównaPytania INF.04 › Pytanie 172
INF.04 · pytanie #172

Przedstawione kody zawierają realizację funkcji oraz jeden zdefiniowany test automatyczny, który weryfikuje działanie funkcji w przypadku, gdy argumentem jest liczba ujemna. W miejsce kropek należy dodać drugi test, który sprawdzi funkcjonalność funkcji, kiedy argumentem jest liczba dodatnia. Który z poniższych kodów jest odpowiedni do tego testu? <br><br> <table><tr><td colspan="2">export function fun1(number) { if (number &lt; 0) number = number * (-1); return number; }</td><td colspan="2">describe('fun1', () =&gt; { it('test1', () =&gt; { const result = fun1(-1); expect(result).toBe(1); }) ... })</td></tr><tr><td>it('test2', () =&gt; { const result = fun1(1); expect(result).toBe(result+1); })</td><td>A.</td><td>it('test2', () =&gt; { const result = fun1(2); expect(result).toBe(-2); })</td><td>B.</td></tr><tr><td>it('test2', () =&gt; { const result = fun1(2); expect(result).toBe(2); })</td><td>C.</td><td>it('test2', () =&gt; { const result = fun1(1); expect(result).toBe(-1); })</td><td>D.</td></tr></table>

Kliknij odpowiedź, którą uważasz za poprawną.