Efter Donald Trumps hot om att stoppa handeln med Spanien har landet gått med på att samarbeta med USA:s militär, uppger Vita huset.