how to test ajax request in custom component made by polymer

93 views Asked by At

component html file part where request is being send

       <paper-button class="indigo" style="margin-top:1em; width:15%" 
        on-tap="sendLoginRequest">Login</paper-button>
         <iron-ajax id="loginAjaxRequest" handle-as="json" on- 
     response="loginResponse" on-error="showToast"></iron-ajax>

sendloginRequest function part where request is fired

        sendLoginRequest() {
         //some code
   this.$.loginAjaxRequest.url = "http://localhost:8080/api/login"
    this.$.loginAjaxRequest.body = JSON.stringify(loginJson)
    this.$.loginAjaxRequest.method = "POST"
    this.$.loginAjaxRequest.generateRequest()
  }

how to write test cases for it

0

There are 0 answers