(done)
| 181 | }; |
| 182 | |
| 183 | export var test_fetch_post_json = function (done) { |
| 184 | // >> fetch-post-json |
| 185 | fetch('https://http-echo.nativescript.org/post', { |
| 186 | method: 'POST', |
| 187 | headers: new Headers({ 'Content-Type': 'application/json' }), |
| 188 | body: JSON.stringify({ MyVariableOne: 'ValueOne', MyVariableTwo: 'ValueTwo' }), |
| 189 | }) |
| 190 | .then((r) => r.json()) |
| 191 | .then(function (r) { |
| 192 | // >> (hide) |
| 193 | TKUnit.assert(r.json['MyVariableOne'] === 'ValueOne' && r.json['MyVariableTwo'] === 'ValueTwo', 'Content not sent/received properly! Actual result is: ' + r.json); |
| 194 | done(null); |
| 195 | // << (hide) |
| 196 | // console.log(result); |
| 197 | }) |
| 198 | .catch(failOnError(done)); |
| 199 | // << fetch-post-json |
| 200 | }; |
| 201 | |
| 202 | const failOnError = function (done: (err: Error, res?: string) => void) { |
| 203 | return (e) => done(e); |
nothing calls this directly
no test coverage detected