It wasn’t because she was pregnant, but because she wasn’t married and was pregnant. Hence the “morality clause.” That said, I think they should have put her on leave immediately and given her time either to rectify the situation by getting married, or to find another job.
I don’t think giving her time to get hitched is a solution, as the problem isn’t being pregnant and not married, the problem is having engaged in consensual marital activity while not being married. Marrying after the fact doesn’t change the status of the activity—and often is only a way to further mess up one’s life.