A childcare worker in mental anguish slapped two young children as they slept, a court has been told.