They pretty much know exactly how it works.
Another reason they know is when two hydrogen atoms fuse together creating helium. There is leftover particles. (ie, two hydrogen atoms are heavier than a single helium atom) Those left over particles are converted to pure energy in the form of gamma rays. (the strongest electromagnetic wave) If those gamma rays just straight left the Sun, that would wash the Earth in a huge amount of gamma radiation. If that happened, we wouldn't exist. Instead, those gamma ray photons bounce around inside the Sun's soup passing that extra energy off. As they keep making their way toward the surface, the strength of that electromagnetic energy is defused.
Gamma rays, x-rays, even ultra-violet aren't visible to the human eye. (though some bugs can see it) Yet, notice how bright the Sun is? That brightness is those same gamma rays that were released just defused down into the visible spectrum!
Obviously, there are lower power electromagnetic waves also that aren't visible to the human eye. (infrared, microwave, and even radio waves) Around the ultra-violet wave length is where they become ionizing radiation. Not all ultra-violet light will harm you, but of course. Some have high enough energy that they will cause a sunburn.
Here is graphic that shows the energy level of an electromagnetic wave. The higher the frequency, the more energy the wave has and the more dangerous it is to humans.
EDIT: Here is a
link that discusses it also.