(actual, expected)
| 34 | } |
| 35 | |
| 36 | function expectArraysClose(actual, expected) { |
| 37 | const actualValues = actual instanceof Array ? actual : actual.dataSync(); |
| 38 | const expectedValues = expected instanceof Array ? expected : expected.dataSync(); |
| 39 | |
| 40 | expect(actualValues.length).toBe(expectedValues.length); |
| 41 | const PRECISION = 3; // corresponds to 1e-3. |
| 42 | for (let i = 0; i < actualValues.length; i++) { |
| 43 | expect(actualValues[i]).toBeCloseTo(expectedValues[i], PRECISION); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | module.exports = {runTests, expectArraysClose}; |
no outgoing calls
no test coverage detected