Let's write a test that verifies we're able to get the right customer by its id. In Customer.re, there is a function called getCustomer that accepts an array of customers, and imperatively gets the id by calling getId. The getId function accepts a pathname that exists outside the scope of getCustomer:
let getCustomer = customers => { let id = getId(pathname); customers |> Js.Array.find(customer => customer.CustomerType.id == id);};
Right away, we notice that this is less than ideal. It would be much better if getCustomer accepted an array of customers and an id, and focused on getting the customer by their id. Otherwise, it will be harder to write a test just for getCustomer.
So, we refactor getCustomer to also accept ...