let sut = require("../src/foldCoinChanger"),
	expect = require("expect.js"),
	_ = require("lodash");

describe("foldCoinChanger", () => {
	it("Given register it must return size equal to register", () => {
		expect(sut.foldCoinChanger([], 0)).to.have.length(0);
		expect(sut.foldCoinChanger([1, 2], 0)).to.have.length(2);
		expect(sut.foldCoinChanger([1, 2, 3], 0)).to.have.length(3);
	}),
	it("Given pennies it must return amount", () => {
		let pennies = _.partial(sut.foldCoinChanger, [1]);

		expect(_.first(pennies(0))).to.equal(0);
		expect(_.first(pennies(10))).to.equal(10);
		expect(_.first(pennies(99))).to.equal(99);
	}),
	it("Given full register and amount less than 5 it must return amount as pennies", () => {
		let full = _.partial(sut.foldCoinChanger, [50, 25, 10, 5, 1]);

		expect(_.last(full(1))).to.equal(1);
		expect(_.last(full(3))).to.equal(3);
		expect(_.last(full(4))).to.equal(4);
	}),
	it("Given amount and expected with full register it must return expected", () => {
		let full = _.partial(sut.foldCoinChanger, [50, 25, 10, 5, 1]);

		expect(full(42)).to.eql([0, 1, 1, 1, 2]);
		expect(full(99)).to.eql([1, 1, 2, 0, 4]);
	});
});