Al-Kāfi - Volume 3 > Causes of Death and that Believing People May Die by any Manner of Dying
Hadith #10

10ـ عِدَّةٌ مِنْ أَصْحَابِنَا عَنْ سَهْلِ بْنِ زِيَادٍ عَنْ مُحَمَّدِ بْنِ سِنَانٍ عَنْ عُثْمَانَ النَّوَّاءِ عَمَّنْ ذَكَرَهُ عَنْ أَبِي عَبْدِ الله (عَلَيْهِ الْسَّلام) قَالَ إِنَّ الله عَزَّ وَجَلَّ يَبْتَلِي الْمُؤْمِنَ بِكُلِّ بَلِيَّةٍ وَيُمِيتُهُ بِكُلِّ مِيتَةٍ وَلاَ يَبْتَلِيهِ بِذَهَابِ عَقْلِهِ أَ مَا تَرَى أَيُّوبَ (عَلَيْهِ الْسَّلام) كَيْفَ سَلَّطَ إِبْلِيسَ عَلَى مَالِهِ وَوُلْدِهِ وَعَلَى أَهْلِهِ وَعَلَى كُلِّ شَيْ‏ءٍ مِنْهُ وَلَمْ يُسَلِّطْهُ عَلَى عَقْلِهِ تَرَكَ لَهُ مَا يُوَحِّدُ الله عَزَّ وَجَلَّ بِهِ.

10. A number of our people have narrated from Sahl ibn Ziyad from Muhammad ibn Sinan from ‘Uthman al-Nawwa’ from those whom he has mentioned (in his book) who has said the following: “Abu ’Abd Allah, ‘Alayhi al-Salam, has said that Allah, the Majestic, the Glorious, places a believing person under any kind of test and trial and causes him or her to die by any form of death but He does not cause him or her to suffer the loss of reason. Consider the case of prophet Ayyub, how Satan controlled his property, children and family and all things that were his, but not his reason. It remained with him so he could worship thereby and maintain his belief in Allah, the Majestic, the Glorious.”