It means if the reason you're being tried is for having faith in Christ then that should give you assurance that you're living as you should and Christ will reward you for doing so.
All trials in life require faith and standing strong; if you can get past the worst trials in your life, you will cross over the finish line victorious and cheering. You did it, you passed the test!
I expect for the same reason that every other person of any other religion or without religion is able to be joyful. Human, ( not just Christians) are resilient. It is how we are made, it is our nature to adapt to the reality that faces us. The sc
This causes unnatural responses sometimes from Christians. I've seen people being "joyful" sfter their mother died.
BECAUSE THEY'RE SADOMASOCHISTS. YES I AM TYPING IN ALL CAPS!