How to test for an hold item name in Minecraft?

You can actually combine this into one command. Prior to 1.13, this would look like this:

/testfor @p[r=10] {SelectedItem:{id:"minecraft:diamond_sword",tag:{display:{Name:"Item Name"}}}}

This will return an output if the player is holding a named diamond sword in the selected slot.

However, the above command has been completely deprecated in 1.13. testfor is now Bedrock only, and the [r=] selector has been changed. You also can't really do anything with this testfor anyway, all it does is give a redstone output. A better and updated version for Java Edition 1.13 would be something along the following lines:

/execute at @p[distance=..10, nbt={SelectedItem:{id:"minecraft:diamond_sword",tag:{display:{Name:"Item Name"}}}}] run <your item spawning command>

This command executes <your item spawning command> at the position of a player within 10 blocks that matches the SelectedItem NBT.