It depends on who changes their mind. If the landlord decides not to rent to the prospective tenant, then the deposit should be refunded in full. If the prospective tenant changes their mind, then usually the landlord may keep the some or all of the deposit, up to the extent they are damaged by the tenant’s breach of the agreement. The landlord should make a good faith attempt to minimize their damages by locating another tenant as quickly as possible.
Note: If the landlord can immediately re-rent the unit and loses no rent as a result of the tenant backing out of the deal, then the tenant should get their money back. The landlord can retain an amount equal to the rent they lose, plus the cost of advertising the unit again, if any.