function prepareTargetWithGivenDirection(dir) {
  style.setStyle(document.body, 'direction', dir);

  fieldDiv.style.direction = dir;
  fieldDiv.innerHTML = '<a href="http://www.google.com">Google</a>';
  link = fieldDiv.firstChild;

  fieldMock.$replay();
  /** @suppress {visibility} suppression added to enable type checking */
  bubblePlugin.createBubbleContents = (bubbleContainer) => {
    bubbleContainer.innerHTML = '<div style="border:1px solid blue;">B</div>';
    style.setStyle(bubbleContainer, 'border', '1px solid white');
  };
  bubblePlugin.registerFieldObject(fieldMock);
  bubblePlugin.enable(fieldMock);
  bubblePlugin.createBubble(link);
}
This is a helper function for setting up the targetElement with a
given direction.
@param {string} dir The direction of the targetElement, 'ltr' or 'rtl'.