When Theresa May called her "snap" general election in May, three years earlier than required by UK electoral law, it was seen as hers to lose.