effects-as-data-http
Advanced tools
+17
-3
@@ -0,1 +1,7 @@ | ||
| const { merge } = require('./util'); | ||
| const defaultHeaders = { | ||
| 'Content-Type': 'application/json;charset=UTF-8' | ||
| }; | ||
| function httpGet(url, headers = {}, options = {}) { | ||
@@ -15,3 +21,3 @@ return { | ||
| payload, | ||
| headers, | ||
| headers: merge(defaultHeaders, headers), | ||
| options | ||
@@ -26,3 +32,3 @@ }; | ||
| payload, | ||
| headers, | ||
| headers: merge(defaultHeaders, headers), | ||
| options | ||
@@ -41,2 +47,9 @@ }; | ||
| function rpc(url, fn, payload) { | ||
| return httpPost(url, { | ||
| fn, | ||
| payload | ||
| }); | ||
| } | ||
| module.exports = { | ||
@@ -46,4 +59,5 @@ httpPost, | ||
| httpGet, | ||
| httpDelete | ||
| httpDelete, | ||
| rpc | ||
| }; | ||
| //# sourceMappingURL=actions.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/actions.js"],"names":["httpGet","url","headers","options","type","httpPost","payload","httpPut","httpDelete","module","exports"],"mappings":"AAAA,SAASA,OAAT,CAAkBC,GAAlB,EAAuBC,UAAU,EAAjC,EAAqCC,UAAU,EAA/C,EAAmD;AACjD,SAAO;AACLC,UAAM,SADD;AAELH,OAFK;AAGLC,WAHK;AAILC;AAJK,GAAP;AAMD;;AAED,SAASE,QAAT,CAAmBJ,GAAnB,EAAwBK,OAAxB,EAAiCJ,UAAU,EAA3C,EAA+CC,UAAU,EAAzD,EAA6D;AAC3D,SAAO;AACLC,UAAM,UADD;AAELH,OAFK;AAGLK,WAHK;AAILJ,WAJK;AAKLC;AALK,GAAP;AAOD;;AAED,SAASI,OAAT,CAAkBN,GAAlB,EAAuBK,OAAvB,EAAgCJ,UAAU,EAA1C,EAA8CC,UAAU,EAAxD,EAA4D;AAC1D,SAAO;AACLC,UAAM,SADD;AAELH,OAFK;AAGLK,WAHK;AAILJ,WAJK;AAKLC;AALK,GAAP;AAOD;;AAED,SAASK,UAAT,CAAqBP,GAArB,EAA0BC,UAAU,EAApC,EAAwCC,UAAU,EAAlD,EAAsD;AACpD,SAAO;AACLC,UAAM,YADD;AAELH,OAFK;AAGLC,WAHK;AAILC;AAJK,GAAP;AAMD;;AAEDM,OAAOC,OAAP,GAAiB;AACfL,UADe;AAEfE,SAFe;AAGfP,SAHe;AAIfQ;AAJe,CAAjB","file":"actions.js","sourcesContent":["function httpGet (url, headers = {}, options = {}) {\n return {\n type: 'httpGet',\n url,\n headers,\n options\n }\n}\n\nfunction httpPost (url, payload, headers = {}, options = {}) {\n return {\n type: 'httpPost',\n url,\n payload,\n headers,\n options\n }\n}\n\nfunction httpPut (url, payload, headers = {}, options = {}) {\n return {\n type: 'httpPut',\n url,\n payload,\n headers,\n options\n }\n}\n\nfunction httpDelete (url, headers = {}, options = {}) {\n return {\n type: 'httpDelete',\n url,\n headers,\n options\n }\n}\n\nmodule.exports = {\n httpPost,\n httpPut,\n httpGet,\n httpDelete\n}\n"]} | ||
| {"version":3,"sources":["../src/actions.js"],"names":["merge","require","defaultHeaders","httpGet","url","headers","options","type","httpPost","payload","httpPut","httpDelete","rpc","fn","module","exports"],"mappings":"AAAA,MAAM,EAAEA,KAAF,KAAYC,QAAQ,QAAR,CAAlB;;AAEA,MAAMC,iBAAiB;AACrB,kBAAgB;AADK,CAAvB;;AAIA,SAASC,OAAT,CAAkBC,GAAlB,EAAuBC,UAAU,EAAjC,EAAqCC,UAAU,EAA/C,EAAmD;AACjD,SAAO;AACLC,UAAM,SADD;AAELH,OAFK;AAGLC,WAHK;AAILC;AAJK,GAAP;AAMD;;AAED,SAASE,QAAT,CAAmBJ,GAAnB,EAAwBK,OAAxB,EAAiCJ,UAAU,EAA3C,EAA+CC,UAAU,EAAzD,EAA6D;AAC3D,SAAO;AACLC,UAAM,UADD;AAELH,OAFK;AAGLK,WAHK;AAILJ,aAASL,MAAME,cAAN,EAAsBG,OAAtB,CAJJ;AAKLC;AALK,GAAP;AAOD;;AAED,SAASI,OAAT,CAAkBN,GAAlB,EAAuBK,OAAvB,EAAgCJ,UAAU,EAA1C,EAA8CC,UAAU,EAAxD,EAA4D;AAC1D,SAAO;AACLC,UAAM,SADD;AAELH,OAFK;AAGLK,WAHK;AAILJ,aAASL,MAAME,cAAN,EAAsBG,OAAtB,CAJJ;AAKLC;AALK,GAAP;AAOD;;AAED,SAASK,UAAT,CAAqBP,GAArB,EAA0BC,UAAU,EAApC,EAAwCC,UAAU,EAAlD,EAAsD;AACpD,SAAO;AACLC,UAAM,YADD;AAELH,OAFK;AAGLC,WAHK;AAILC;AAJK,GAAP;AAMD;;AAED,SAASM,GAAT,CAAcR,GAAd,EAAmBS,EAAnB,EAAuBJ,OAAvB,EAAgC;AAC9B,SAAOD,SAASJ,GAAT,EAAc;AACnBS,MADmB;AAEnBJ;AAFmB,GAAd,CAAP;AAID;;AAEDK,OAAOC,OAAP,GAAiB;AACfP,UADe;AAEfE,SAFe;AAGfP,SAHe;AAIfQ,YAJe;AAKfC;AALe,CAAjB","file":"actions.js","sourcesContent":["const { merge } = require('./util')\n\nconst defaultHeaders = {\n 'Content-Type': 'application/json;charset=UTF-8'\n}\n\nfunction httpGet (url, headers = {}, options = {}) {\n return {\n type: 'httpGet',\n url,\n headers,\n options\n }\n}\n\nfunction httpPost (url, payload, headers = {}, options = {}) {\n return {\n type: 'httpPost',\n url,\n payload,\n headers: merge(defaultHeaders, headers),\n options\n }\n}\n\nfunction httpPut (url, payload, headers = {}, options = {}) {\n return {\n type: 'httpPut',\n url,\n payload,\n headers: merge(defaultHeaders, headers),\n options\n }\n}\n\nfunction httpDelete (url, headers = {}, options = {}) {\n return {\n type: 'httpDelete',\n url,\n headers,\n options\n }\n}\n\nfunction rpc (url, fn, payload) {\n return httpPost(url, {\n fn,\n payload\n })\n}\n\nmodule.exports = {\n httpPost,\n httpPut,\n httpGet,\n httpDelete,\n rpc\n}\n"]} |
+18
-14
| const { httpGet, httpDelete, httpPost, httpPut } = require('./actions'); | ||
| const { deepEqual } = require('assert'); | ||
| const defaultHeaders = { | ||
| 'Content-Type': 'application/json;charset=UTF-8' | ||
| }; | ||
| describe('actions', () => { | ||
@@ -17,5 +21,5 @@ describe('httpGet', () => { | ||
| it('should return an httpGet ', () => { | ||
| it('should return an httpGet', () => { | ||
| const actual = httpGet('http://www.example.com', { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, { | ||
@@ -29,3 +33,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, | ||
@@ -53,5 +57,5 @@ options: { | ||
| it('should return an httpDelete ', () => { | ||
| it('should return an httpDelete', () => { | ||
| const actual = httpDelete('http://www.example.com', { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, { | ||
@@ -65,3 +69,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, | ||
@@ -84,3 +88,3 @@ options: { | ||
| payload: { foo: 'bar' }, | ||
| headers: {}, | ||
| headers: defaultHeaders, | ||
| options: {} | ||
@@ -91,5 +95,5 @@ }; | ||
| it('should return an httpPost ', () => { | ||
| it.only('should return an httpPost', () => { | ||
| const actual = httpPost('http://www.example.com', { foo: 'bar' }, { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, { | ||
@@ -104,3 +108,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, | ||
@@ -123,3 +127,3 @@ options: { | ||
| payload: { foo: 'bar' }, | ||
| headers: {}, | ||
| headers: defaultHeaders, | ||
| options: {} | ||
@@ -130,5 +134,5 @@ }; | ||
| it('should return an httpPut ', () => { | ||
| it('should return an httpPut', () => { | ||
| const actual = httpPut('http://www.example.com', { foo: 'bar' }, { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, { | ||
@@ -143,3 +147,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, | ||
@@ -146,0 +150,0 @@ options: { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/actions.spec.js"],"names":["httpGet","httpDelete","httpPost","httpPut","require","deepEqual","describe","it","actual","expected","type","url","headers","options","credentials","foo","payload"],"mappings":"AAAA,MAAM,EAAEA,OAAF,EAAWC,UAAX,EAAuBC,QAAvB,EAAiCC,OAAjC,KAA6CC,QAAQ,WAAR,CAAnD;AACA,MAAM,EAAEC,SAAF,KAAgBD,QAAQ,QAAR,CAAtB;;AAEAE,SAAS,SAAT,EAAoB,MAAM;AACxBA,WAAS,SAAT,EAAoB,MAAM;AACxBC,OAAG,iCAAH,EAAsC,MAAM;AAC1C,YAAMC,SAASR,QAAQ,wBAAR,CAAf;AACA,YAAMS,WAAW;AACfC,cAAM,SADS;AAEfC,aAAK,wBAFU;AAGfC,iBAAS,EAHM;AAIfC,iBAAS;AAJM,OAAjB;AAMAR,gBAAUG,MAAV,EAAkBC,QAAlB;AACD,KATD;;AAWAF,OAAG,2BAAH,EAAgC,MAAM;AACpC,YAAMC,SAASR,QAAQ,wBAAR,EAAkC;AAC/C,wBAAgB;AAD+B,OAAlC,EAEZ;AACDc,qBAAa;AADZ,OAFY,CAAf;;AAMA,YAAML,WAAW;AACfC,cAAM,SADS;AAEfC,aAAK,wBAFU;AAGfC,iBAAS;AACP,0BAAgB;AADT,SAHM;AAMfC,iBAAS;AACPC,uBAAa;AADN;AANM,OAAjB;;AAWAT,gBAAUG,MAAV,EAAkBC,QAAlB;AACD,KAnBD;AAoBD,GAhCD;;AAkCAH,WAAS,YAAT,EAAuB,MAAM;AAC3BC,OAAG,oCAAH,EAAyC,MAAM;AAC7C,YAAMC,SAASP,WAAW,wBAAX,CAAf;AACA,YAAMQ,WAAW;AACfC,cAAM,YADS;AAEfC,aAAK,wBAFU;AAGfC,iBAAS,EAHM;AAIfC,iBAAS;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MC,SAASL,QAAQ,wBAAR,EAAkC,EAACY,KAAK,KAAN,EAAlC,CAAf;AACA,YAAMN,WAAW;AACfC,cAAM,SADS;AAEfC,aAAK,wBAFU;AAGfK,iBAAS,EAACD,KAAK,KAAN,EAHM;AAIfH,iBAAS,EAJM;AAKfC,iBAAS;AALM,OAAjB;AAOAR,gBAAUG,MAAV,EAAkBC,QAAlB;AACD,KAVD;;AAYAF,OAAG,2BAAH,EAAgC,MAAM;AACpC,YAAMC,SAASL,QAAQ,wBAAR,EAAkC,EAACY,KAAK,KAAN,EAAlC,EAAgD;AAC7D,wBAAgB;AAD6C,OAAhD,EAEZ;AACDD,qBAAa;AADZ,OAFY,CAAf;;AAMA,YAAML,WAAW;AACfC,cAAM,SADS;AAEfC,aAAK,wBAFU;AAGfK,iBAAS,EAACD,KAAK,KAAN,EAHM;AAIfH,iBAAS;AACP,0BAAgB;AADT,SAJM;AAOfC,iBAAS;AACPC,uBAAa;AADN;AAPM,OAAjB;;AAYAT,gBAAUG,MAAV,EAAkBC,QAAlB;AACD,KApBD;AAqBD,GAlCD;AAmCD,CA5ID","file":"actions.spec.js","sourcesContent":["const { httpGet, httpDelete, httpPost, httpPut } = require('./actions')\nconst { deepEqual } = require('assert')\n\ndescribe('actions', () => {\n describe('httpGet', () => {\n it('should return an httpGet object', () => {\n const actual = httpGet('http://www.example.com')\n const expected = {\n type: 'httpGet',\n url: 'http://www.example.com',\n headers: {},\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpGet ', () => {\n const actual = httpGet('http://www.example.com', {\n 'Content-type': 'application/json'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpGet',\n url: 'http://www.example.com',\n headers: {\n 'Content-type': 'application/json'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n\n describe('httpDelete', () => {\n it('should return an httpDelete object', () => {\n const actual = httpDelete('http://www.example.com')\n const expected = {\n type: 'httpDelete',\n url: 'http://www.example.com',\n headers: {},\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpDelete ', () => {\n const actual = httpDelete('http://www.example.com', {\n 'Content-type': 'application/json'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpDelete',\n url: 'http://www.example.com',\n headers: {\n 'Content-type': 'application/json'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n\n describe('httpPost', () => {\n it('should return an httpPost object', () => {\n const actual = httpPost('http://www.example.com', {foo: 'bar'})\n const expected = {\n type: 'httpPost',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: {},\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpPost ', () => {\n const actual = httpPost('http://www.example.com', {foo: 'bar'}, {\n 'Content-type': 'application/json'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpPost',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: {\n 'Content-type': 'application/json'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n\n describe('httpPut', () => {\n it('should return an httpPut object', () => {\n const actual = httpPut('http://www.example.com', {foo: 'bar'})\n const expected = {\n type: 'httpPut',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: {},\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpPut ', () => {\n const actual = httpPut('http://www.example.com', {foo: 'bar'}, {\n 'Content-type': 'application/json'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpPut',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: {\n 'Content-type': 'application/json'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n})\n"]} | ||
| {"version":3,"sources":["../src/actions.spec.js"],"names":["httpGet","httpDelete","httpPost","httpPut","require","deepEqual","defaultHeaders","describe","it","actual","expected","type","url","headers","options","credentials","foo","payload","only"],"mappings":"AAAA,MAAM,EAAEA,OAAF,EAAWC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AT,gBAAUI,MAAV,EAAkBC,QAAlB;AACD,KAVD;;AAYAF,OAAG,0BAAH,EAA+B,MAAM;AACnC,YAAMC,SAASN,QAAQ,wBAAR,EAAkC,EAACa,KAAK,KAAN,EAAlC,EAAgD;AAC7D,wBAAgB;AAD6C,OAAhD,EAEZ;AACDD,qBAAa;AADZ,OAFY,CAAf;;AAMA,YAAML,WAAW;AACfC,cAAM,SADS;AAEfC,aAAK,wBAFU;AAGfK,iBAAS,EAACD,KAAK,KAAN,EAHM;AAIfH,iBAAS;AACP,0BAAgB;AADT,SAJM;AAOfC,iBAAS;AACPC,uBAAa;AADN;AAPM,OAAjB;;AAYAV,gBAAUI,MAAV,EAAkBC,QAAlB;AACD,KApBD;AAqBD,GAlCD;AAmCD,CA5ID","file":"actions.spec.js","sourcesContent":["const { httpGet, httpDelete, httpPost, httpPut } = require('./actions')\nconst { deepEqual } = require('assert')\n\nconst defaultHeaders = {\n 'Content-Type': 'application/json;charset=UTF-8'\n}\n\ndescribe('actions', () => {\n describe('httpGet', () => {\n it('should return an httpGet object', () => {\n const actual = httpGet('http://www.example.com')\n const expected = {\n type: 'httpGet',\n url: 'http://www.example.com',\n headers: {},\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpGet', () => {\n const actual = httpGet('http://www.example.com', {\n 'Content-Type': 'application/json'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpGet',\n url: 'http://www.example.com',\n headers: {\n 'Content-Type': 'application/json'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n\n describe('httpDelete', () => {\n it('should return an httpDelete object', () => {\n const actual = httpDelete('http://www.example.com')\n const expected = {\n type: 'httpDelete',\n url: 'http://www.example.com',\n headers: {},\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpDelete', () => {\n const actual = httpDelete('http://www.example.com', {\n 'Content-Type': 'application/json'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpDelete',\n url: 'http://www.example.com',\n headers: {\n 'Content-Type': 'application/json'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n\n describe('httpPost', () => {\n it('should return an httpPost object', () => {\n const actual = httpPost('http://www.example.com', {foo: 'bar'})\n const expected = {\n type: 'httpPost',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: defaultHeaders,\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it.only('should return an httpPost', () => {\n const actual = httpPost('http://www.example.com', {foo: 'bar'}, {\n 'Content-Type': 'text/html'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpPost',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: {\n 'Content-Type': 'text/html'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n\n describe('httpPut', () => {\n it('should return an httpPut object', () => {\n const actual = httpPut('http://www.example.com', {foo: 'bar'})\n const expected = {\n type: 'httpPut',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: defaultHeaders,\n options: {}\n }\n deepEqual(actual, expected)\n })\n\n it('should return an httpPut', () => {\n const actual = httpPut('http://www.example.com', {foo: 'bar'}, {\n 'Content-Type': 'text/html'\n }, {\n credentials: 'include'\n })\n\n const expected = {\n type: 'httpPut',\n url: 'http://www.example.com',\n payload: {foo: 'bar'},\n headers: {\n 'Content-Type': 'text/html'\n },\n options: {\n credentials: 'include'\n }\n }\n\n deepEqual(actual, expected)\n })\n })\n})\n"]} |
+1
-1
| { | ||
| "name": "effects-as-data-http", | ||
| "version": "0.0.5", | ||
| "version": "0.0.7", | ||
| "description": "Http for effects-as-data", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
+17
-3
@@ -0,1 +1,7 @@ | ||
| const { merge } = require('./util') | ||
| const defaultHeaders = { | ||
| 'Content-Type': 'application/json;charset=UTF-8' | ||
| } | ||
| function httpGet (url, headers = {}, options = {}) { | ||
@@ -15,3 +21,3 @@ return { | ||
| payload, | ||
| headers, | ||
| headers: merge(defaultHeaders, headers), | ||
| options | ||
@@ -26,3 +32,3 @@ } | ||
| payload, | ||
| headers, | ||
| headers: merge(defaultHeaders, headers), | ||
| options | ||
@@ -41,2 +47,9 @@ } | ||
| function rpc (url, fn, payload) { | ||
| return httpPost(url, { | ||
| fn, | ||
| payload | ||
| }) | ||
| } | ||
| module.exports = { | ||
@@ -46,3 +59,4 @@ httpPost, | ||
| httpGet, | ||
| httpDelete | ||
| httpDelete, | ||
| rpc | ||
| } |
+18
-14
| const { httpGet, httpDelete, httpPost, httpPut } = require('./actions') | ||
| const { deepEqual } = require('assert') | ||
| const defaultHeaders = { | ||
| 'Content-Type': 'application/json;charset=UTF-8' | ||
| } | ||
| describe('actions', () => { | ||
@@ -17,5 +21,5 @@ describe('httpGet', () => { | ||
| it('should return an httpGet ', () => { | ||
| it('should return an httpGet', () => { | ||
| const actual = httpGet('http://www.example.com', { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, { | ||
@@ -29,3 +33,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, | ||
@@ -53,5 +57,5 @@ options: { | ||
| it('should return an httpDelete ', () => { | ||
| it('should return an httpDelete', () => { | ||
| const actual = httpDelete('http://www.example.com', { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, { | ||
@@ -65,3 +69,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'application/json' | ||
| }, | ||
@@ -84,3 +88,3 @@ options: { | ||
| payload: {foo: 'bar'}, | ||
| headers: {}, | ||
| headers: defaultHeaders, | ||
| options: {} | ||
@@ -91,5 +95,5 @@ } | ||
| it('should return an httpPost ', () => { | ||
| it.only('should return an httpPost', () => { | ||
| const actual = httpPost('http://www.example.com', {foo: 'bar'}, { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, { | ||
@@ -104,3 +108,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, | ||
@@ -123,3 +127,3 @@ options: { | ||
| payload: {foo: 'bar'}, | ||
| headers: {}, | ||
| headers: defaultHeaders, | ||
| options: {} | ||
@@ -130,5 +134,5 @@ } | ||
| it('should return an httpPut ', () => { | ||
| it('should return an httpPut', () => { | ||
| const actual = httpPut('http://www.example.com', {foo: 'bar'}, { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, { | ||
@@ -143,3 +147,3 @@ credentials: 'include' | ||
| headers: { | ||
| 'Content-type': 'application/json' | ||
| 'Content-Type': 'text/html' | ||
| }, | ||
@@ -146,0 +150,0 @@ options: { |
42631
3.61%792
3.66%