All files / src/messemger-renderer createElement.js

100% Statements 9/9
50% Branches 1/2
100% Functions 7/7
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21      71x 71x 17x 6x 20x 3x 11x 14x       71x            
import { Message, Text, Response, SenderAction, Attachment, QuickReply } from '../components/Messaging';
 
function createElement(type, props, root) {
  console.log('creating element', type, props, root)
  const COMPONENTS = {
    MESSAGE: () => new Message(root, props),
    TEXT: () => new Text(root, props),
    RESPONSE: () => new Response(),
    SENDER_ACTION: () => new SenderAction(root, props),
    ATTACHMENT: () => new Attachment(root, props),
    QUICKREPLY: () => new QuickReply(root, props),
    default: undefined
  };
 
  return COMPONENTS[type]() || COMPONENTS.default;
}
 
export {
  createElement
};