1 |
|
2 | const expect = require('expect.js');
|
3 | const Cmd = require('../src/debugger/lib/cmd');
|
4 |
|
5 | describe('Cmd Core Test', function () {
|
6 | describe('Cmd test ', function () {
|
7 |
|
8 | it('the not inptu test', function () {
|
9 | let cmd = new Cmd();
|
10 | expect(cmd._session).to.be.equal(undefined);
|
11 | })
|
12 |
|
13 | it('shuold pass "session"', function () {
|
14 | let session = {}
|
15 | let cmd = new Cmd(session);
|
16 | expect(cmd._session).to.be.a(Object);
|
17 | })
|
18 |
|
19 | it('httpRequest test ok', function () {
|
20 | let session = {}
|
21 | let cmd = new Cmd(session);
|
22 | expect(cmd.httpRequest).to.be.a('function');
|
23 | expect(function () {
|
24 | cmd.httpRequest('Post', 'www.xxx.com', { ssToken: 'token' }, { ssCode: '[1,3,5]' });
|
25 | }).to.throwException('this._session.httpRequest is not a function');
|
26 | })
|
27 |
|
28 | it('httpGet test ok', function () {
|
29 | let session = {
|
30 | httpRequest: function (method, url, header, body, ev = "fetch") {
|
31 | return { method, url, header, body, ev }
|
32 | }
|
33 | }
|
34 | let cmd = new Cmd(session);
|
35 | expect(cmd.httpGet).to.be.a('function');
|
36 | let result = cmd.httpGet('www.xxx.com', { ssToken: 'token' }, { ssCode: '[1,3,5]' });
|
37 | expect(result).to.not.be.empty();
|
38 | })
|
39 |
|
40 | it('cmdList test ok', function () {
|
41 | let cmd = new Cmd();
|
42 | let result = cmd.cmdList();
|
43 | expect(result).to.be.an('array');
|
44 | expect(result).to.not.be.empty();
|
45 | })
|
46 |
|
47 | it('nameList test ok', function () {
|
48 | let cmd = new Cmd();
|
49 | let result = cmd.nameList();
|
50 | expect(result).to.contain('http', 'get', 'post', 'lastHttpResponse', 'setScript', 'source', 'enableReport', 'disableReport', 'showBrowser');
|
51 | })
|
52 | })
|
53 | }) |
\ | No newline at end of file |