All files / src/attachments BaseAttachment.js

100% Statements 12/12
100% Branches 6/6
100% Functions 1/1
100% Lines 12/12

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        13x 13x 13x 13x   13x   13x 9x     13x 5x     13x 4x     13x                    
class BaseAttachment {
  constructor({
    type, url, is_reusable, attachment_id,
  }) {
    this.type = type;
    this.url = url;
    this.is_reusable = is_reusable;
    this.attachment_id = attachment_id;
 
    const payload = {};
 
    if (this.url) {
      payload.url = url;
    }
 
    if (this.is_reusable) {
      payload.is_reusable = is_reusable;
    }
 
    if (this.attachment_id) {
      payload.attachment_id = attachment_id;
    }
 
    return {
      attachment: {
        type: this.type,
        payload,
      },
    };
  }
}
 
export default BaseAttachment;