Apple has been surprisingly good to me with battery replacements. Basically if it's within the computer's warranty period, and the battery says
it's bad, they replace it for free. It will show a status of "Check Battery" in system profiler. If the batter is "consumed" (you have exceeded its recommended cycle count) it will probably have a status of "Replace Battery", and they may not replace it.
For a long time, and until only somewhat recently, batteries were expected to last 300 cycles. But the advent of non-replaceable batteries caused a shift in this policy, and now batteries are expected to last 1,000 cycles. So odds are good that by the time you have a battery problem, it's going to be out of warranty. (or it will have its problem under warranty and will be replaced for free)
In a few cases you get more than just the battery. Some macs had the battery glued
to the underside of the top case, and so you get a whole new top case, complete with new keyboard too. iirc that was on a group of macbook airs.
If your battery is swelling, Apple may pay for further repairs, and has been known to cover repairs on machines that are out of warranty. I've seen some impressive "airbags deployed" in my time. Swelling batteries typically caused problems with the laptop rocking on the table, problems with clicking the trackpad button, and ultimately being difficult or impossible to remove. I recall having to mail in a couple of laptops for battery replacement because I couldn't get the old one out. Those came back with some parts replaced, as they must have had to break in to relieve the latch.http://vftp.net/mac_disasters/batteries_swelling/