'use strict'; const assert = require('assert'); const { sum } = require('./sum'); const test = (description, testProcedure) => ({ description, test: testProcedure, }); const testSumCorrectness = test( '#sum should return the sum of its arguments', () => { const a = 1; const b = 2; const result = sum(a, b); assert(result === a + b, 'the result should be the sum of its arguments'); } ); const testSumNoArgs = test( '#sum should throw an error if no arguments are passed', () => { try { sum(); } catch { return; } assert.fail('should fail if not provided any arguments'); } ); const testSumMissingArg = test( '#sum should throw an error if no arguments are passed', () => { const a = 1; try { sum(a); } catch { return; } assert.fail('should fail if not provided all arguments'); } ); const testWillFail = test( '#sum will fail against its will', () => { assert.fail('I have failed!'); } ); module.exports = { testSumCorrectness, testSumNoArgs, testSumMissingArg, testWillFail, };