{"size": 1055, "ext": "js", "max_stars_repo_path": "ch5/calculate-with-log.spec.js", "max_stars_repo_name": "mike-holcomb/aout3-samples", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "ch5/calculate-with-log.spec.js", "max_issues_repo_name": "mike-holcomb/aout3-samples", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "ch5/calculate-with-log.spec.js", "max_forks_repo_name": "mike-holcomb/aout3-samples", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.7631578947, "max_line_length": 69, "alphanum_fraction": 0.4720379147}
const Samples =  require('./calculate-with-log');

describe('calculate', () => {
    describe('given two numbers', () => {
        it('sums them up', () => {
            const result = Samples.calculate(1, 2,
                                            jest.fn());
            expect(result).toBe(3);
        });

        it('calls the logger with sum', () => {
            const logger = jest.fn();

            const result = Samples.calculate(1, 2, logger);

            expect(logger.mock.calls.length).toBe(1);
            expect(logger.mock.calls[0][0]).toBe(3);
        });
    });
});
describe('calculate2', () => {
    describe('given two numbers', () => {
        it('sums them up', () => {
            const result = Samples.calculate2(1, 2, {log:jest.fn()});
            expect(result).toBe(3);
        });

        it('calls the logger with sum', () => {
            const mockLogger = {log: jest.fn()}

            Samples.calculate2(1, 2, mockLogger);

            expect(mockLogger.log.mock.calls.length).toBe(1);
        });
    });
});

