http.test.js 894 B

12345678910111213141516171819202122232425262728293031323334
  1. var Vue = require('vue');
  2. var VueResource = require('../dist/vue-resource.common.js');
  3. Vue.use(VueResource);
  4. describe('Vue.http', function () {
  5. it('post("jsfiddle.net/html")', () => {
  6. return Vue.http.post('http://jsfiddle.net/echo/html/', {html: 'text'}, {emulateJSON: true}).then(res => {
  7. expect(res.ok).toBe(true);
  8. expect(res.status).toBe(200);
  9. expect(typeof res.body).toBe('string');
  10. expect(res.body).toBe('text');
  11. });
  12. });
  13. it('post("jsfiddle.net/json")', () => {
  14. return Vue.http.post('http://jsfiddle.net/echo/json/', {json: JSON.stringify({foo: 'bar'})}, {emulateJSON: true}).then(res => {
  15. expect(res.ok).toBe(true);
  16. expect(res.status).toBe(200);
  17. expect(typeof res.body).toBe('object');
  18. expect(res.body.foo).toBe('bar');
  19. });
  20. });
  21. });