Republican Ted Cruz has won a third consecutive term as a U.S. senator from Texas after a tough challenge from a former NFL star.