-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
74 lines (58 loc) · 2.16 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
var jsdom = require("jsdom");
global.window = new jsdom.JSDOM().window;
global.document = window.document;
global.CustomEvent = require("custom-event");
var Vue = require("vue");
var ajax = require("../src/vuejs-ajax");
Vue.use(ajax);
describe('Vue.ajax', function () {
it('Vue.ajax.get()', () => {
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return Vue.ajax.get('https://postman-echo.com/get', {foo: 'bar'}).then(res => {
expect(res.xhrStatus).toBe('Complete');
done();
});
});
it('Vue.ajax.post()', () => {
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return Vue.ajax.post('https://postman-echo.com/post', {foo: 'bar'}).then(res => {
expect(res.xhrStatus).toBe('Complete');
done();
});
});
it('Vue.ajax.put()', () => {
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return Vue.ajax.put('https://postman-echo.com/put', {foo: 'bar'}).then(res => {
expect(res.xhrStatus).toBe('Complete');
done();
});
});
it('Vue.ajax.patch()', () => {
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return Vue.ajax.patch('https://postman-echo.com/patch', {foo: 'bar'}).then(res => {
expect(res.xhrStatus).toBe('Complete');
done();
});
});
it('Vue.ajax.delete()', () => {
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return Vue.ajax.delete('https://postman-echo.com/delete', {foo: 'bar'}).then(res => {
expect(res.xhrStatus).toBe('Complete');
done();
});
});
it('Vue.ajax()', () => {
XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
return Vue.ajax({
url: 'https://postman-echo.com/get'
}).then(res => {
expect(res.xhrStatus).toBe('Complete');
done();
});
});
});