<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic WAB unit testing,handling XMLHttpRequest response in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879904#M14008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;BR /&gt;I am working on unit testing of my custom widget. I am unable to receive the response from XMLHttpRequest requests.Can some one please help me.Here I have copied a simple XML HTTP request.I am getting the same problem with dojoPromise response as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unit test method----&lt;/P&gt;&lt;P&gt;'Test getTravelModes':function(){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var defferd = this.async(1000);&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;testApp.getTravelModes().then(defferd.callback(&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;function(data) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(data);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;assert.equal(response,8,'travel modes count matches');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}, function(err) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(err);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}));&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt;widget method----&lt;BR /&gt;getTravelModes:function(){&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var travelModes = [];&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var xhr = new XMLHttpRequest();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xhr.onreadystatechange = function() {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(this.status + " " + this.readyState);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (this.readyState == 4 &amp;amp;&amp;amp; this.status == 200) {&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(this.responseText.indexOf("error") == -1){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for(var i=0;i&amp;lt;JSON.parse(this.responseText).supportedTravelModes.length;i++){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;travelModes.push(JSON.parse(this.responseText).supportedTravelModes&lt;I&gt;.name);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return travelModes; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; xhr.open("POST", "https://hostname/rest/services/Routing/NetworkAnalysis/NAServer/Route_World/retrieveTravelModes",false);&lt;BR /&gt; xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");&lt;BR /&gt; var chkParams = "token="+tokenValue+"&amp;amp;f=json";&lt;BR /&gt; xhr.send(chkParams);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sandhya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Apr 2020 17:43:10 GMT</pubDate>
    <dc:creator>sandhyabaratam</dc:creator>
    <dc:date>2020-04-10T17:43:10Z</dc:date>
    <item>
      <title>WAB unit testing,handling XMLHttpRequest response</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879904#M14008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;BR /&gt;I am working on unit testing of my custom widget. I am unable to receive the response from XMLHttpRequest requests.Can some one please help me.Here I have copied a simple XML HTTP request.I am getting the same problem with dojoPromise response as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unit test method----&lt;/P&gt;&lt;P&gt;'Test getTravelModes':function(){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var defferd = this.async(1000);&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;testApp.getTravelModes().then(defferd.callback(&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;function(data) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(data);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;assert.equal(response,8,'travel modes count matches');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}, function(err) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(err);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}));&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt;widget method----&lt;BR /&gt;getTravelModes:function(){&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var travelModes = [];&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var xhr = new XMLHttpRequest();&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xhr.onreadystatechange = function() {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;console.log(this.status + " " + this.readyState);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (this.readyState == 4 &amp;amp;&amp;amp; this.status == 200) {&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(this.responseText.indexOf("error") == -1){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for(var i=0;i&amp;lt;JSON.parse(this.responseText).supportedTravelModes.length;i++){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;travelModes.push(JSON.parse(this.responseText).supportedTravelModes&lt;I&gt;.name);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return travelModes; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; xhr.open("POST", "https://hostname/rest/services/Routing/NetworkAnalysis/NAServer/Route_World/retrieveTravelModes",false);&lt;BR /&gt; xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");&lt;BR /&gt; var chkParams = "token="+tokenValue+"&amp;amp;f=json";&lt;BR /&gt; xhr.send(chkParams);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sandhya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2020 17:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879904#M14008</guid>
      <dc:creator>sandhyabaratam</dc:creator>
      <dc:date>2020-04-10T17:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: WAB unit testing,handling XMLHttpRequest response</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879905#M14009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Can someone please help with this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2020 09:02:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879905#M14009</guid>
      <dc:creator>sandhyabaratam</dc:creator>
      <dc:date>2020-04-13T09:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: WAB unit testing,handling XMLHttpRequest response</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879906#M14010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is seriously only one or two people that have posted on Geonet about unit testing when it comes to widgets. So there is probably not going to much help from the community on this subject.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2020 12:38:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-unit-testing-handling-xmlhttprequest-response/m-p/879906#M14010</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2020-04-13T12:38:50Z</dc:date>
    </item>
  </channel>
</rss>

