# All files / my/app app.js

100% Statements 11/11
75% Branches 3/4
100% Functions 5/5
100% Lines 10/10

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

    1x
    1x

    9x

    3x
    3x

    3x

    1x
    1x
    1x

    24x

     /*
     * Copyright (c) 2021, salesforce.com, inc.
     * All rights reserved.
     * Licensed under the BSD 3-Clause license.
     * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
     */
    import { LightningElement, track } from 'lwc';
    import LWCBuilderEvent from 'domain/lwcBuilderEvent';

    export default class App extends LightningElement {
      @track contents;
      vscode;

      connectedCallback() {
        Eif (typeof acquireVsCodeApi === 'function') {
          this.vscode = acquireVsCodeApi(); // eslint-disable-line
        }
      }

      onUpdateForm(event) {
        this.contents = event.detail;
      }

      onButtonClick() {
        // Send message to server
        const message = new LWCBuilderEvent('create_button_clicked', this.contents);
        console.log(this.contents);
        this.vscode?.postMessage(message);
      }

      get hasContents() {
        return this.contents && this.contents.componentName;
      }
    }