willpower
Willpower is the strength of your mind and your determination. It is what allows you to resist temptation or to do something that is difficult.
She had a lot of willpower and was able to resist the temptation to eat the cake.
His willpower was tested when he tried to eat the cake, but he was able to resist.