All files / src/elements Element.js

100% Statements 23/23
100% Branches 20/20
100% Functions 1/1
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                        8x 8x 8x 8x 8x 8x 8x 8x 8x   8x           8x 6x     8x 1x     8x 1x     8x 1x     8x 6x     8x 1x     8x          
class Element {
  constructor({
    title,
    item_url = '',
    image_url = '',
    subtitle = '',
    quantity = '',
    price = '',
    currency = '',
    buttons = '',
    default_action = '',
  }) {
    this.title = title;
    this.item_url = item_url;
    this.image_url = image_url;
    this.subtitle = subtitle;
    this.quantity = quantity;
    this.price = price;
    this.currency = currency;
    this.buttons = buttons;
    this.default_action = default_action;
 
    const res = {
      title: this.title,
      image_url: this.image_url,
      subtitle: this.subtitle,
    };
 
    if (this.item_url) {
      res.item_url = this.item_url;
    }
 
    if (this.quantity) {
      res.quantity = this.quantity;
    }
 
    if (this.currency) {
      res.currency = this.currency;
    }
 
    if (this.price) {
      res.price = this.price;
    }
 
    if (this.buttons) {
      res.buttons = this.buttons;
    }
 
    if (this.default_action) {
      res.default_action = this.default_action;
    }
 
    return res;
  }
}
 
export default Element;