|
| 1 | +const ResistorDivider = require("./Resistor-Divider"); |
| 2 | + |
| 3 | + |
| 4 | +describe('ResistorDivider', () => { |
| 5 | + |
| 6 | + test('if input voltage is 10 and both resistors are 1000 then output voltage should be 5', () => { |
| 7 | + expect(ResistorDivider.calcOutputVoltage(10, 1000, 1000)).toEqual({ |
| 8 | + outputVoltage: 5 |
| 9 | + }) |
| 10 | + }); |
| 11 | + |
| 12 | + test('if input voltage is 10, resistor1 is 10000, and resistor2 is 780 then output voltage should be 0.7235621521335807', () => { |
| 13 | + expect(ResistorDivider.calcOutputVoltage(10, 10000, 780)).toEqual({ |
| 14 | + outputVoltage: 0.7235621521335807 |
| 15 | + }) |
| 16 | + }); |
| 17 | + |
| 18 | + test('if input voltage is 10, resistor1 is 1000, and output voltage is 5 then resistor 2 should be 1000', () => { |
| 19 | + expect(ResistorDivider.calcResistor2(10, 5, 1000)).toEqual({ |
| 20 | + resistor2: 1000 |
| 21 | + }) |
| 22 | + }); |
| 23 | + |
| 24 | + test('if input voltage is 10, resistor1 is 10000, and output voltage is 0.7235621521335807 then resistor 2 should be 780', () => { |
| 25 | + expect(ResistorDivider.calcResistor2(10, 0.7235621521335807, 10000)).toEqual({ |
| 26 | + resistor2: 780 |
| 27 | + }) |
| 28 | + }); |
| 29 | + |
| 30 | + test('if input voltage is 10, resistor2 is 1000, and output voltage is 5 then resistor 1 should be 1000', () => { |
| 31 | + expect(ResistorDivider.calcResistor1(10, 5, 1000)).toEqual({ |
| 32 | + resistor1: 1000 |
| 33 | + }) |
| 34 | + }); |
| 35 | + |
| 36 | + test('if input voltage is 10, resistor2 is 780, and output voltage is 0.7235621521335807 then resistor 1 should be 10000', () => { |
| 37 | + expect(ResistorDivider.calcResistor1(10, 0.7235621521335807, 780)).toEqual({ |
| 38 | + resistor1: 10000 |
| 39 | + }) |
| 40 | + }); |
| 41 | + |
| 42 | + test('if output voltage is 5 and both resistors are 1000 then input voltage should be 10', () => { |
| 43 | + expect(ResistorDivider.calcInputVoltage(5, 1000, 1000)).toEqual({ |
| 44 | + inputVoltage: 10 |
| 45 | + }) |
| 46 | + }); |
| 47 | + |
| 48 | + test('if output voltage is 0.7235621521335807, resistor1 is 10000, and resistor2 is 780 then then input voltage should be 9.999999999999998', () => { |
| 49 | + expect(ResistorDivider.calcInputVoltage(0.7235621521335807, 10000, 780)).toEqual({ |
| 50 | + inputVoltage: 9.999999999999998 |
| 51 | + }) |
| 52 | + }); |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +}); |
0 commit comments