itoolkit 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +5 -0
  2. package/lib/CommandCall.js +2 -16
  3. package/lib/Connection.js +2 -16
  4. package/lib/Deprecated.js +2 -22
  5. package/lib/ProgramCall.js +2 -16
  6. package/lib/itoolkit.js +2 -16
  7. package/lib/transports/httpTransport.js +2 -16
  8. package/lib/transports/idbTransport.js +2 -16
  9. package/lib/transports/odbcTransport.js +2 -16
  10. package/lib/transports/sshTransport.js +2 -16
  11. package/package.json +11 -5
  12. package/.eslintrc.js +0 -39
  13. package/.gitattributes +0 -2
  14. package/.readthedocs.yml +0 -16
  15. package/CHANGELOG.md +0 -228
  16. package/contributors.txt +0 -2
  17. package/test/README.md +0 -44
  18. package/test/functional/CommandCallFunctional.js +0 -87
  19. package/test/functional/ProgramCallFunctional.js +0 -106
  20. package/test/functional/checkObjectExists.js +0 -193
  21. package/test/functional/checkVersion.js +0 -17
  22. package/test/functional/config.js +0 -35
  23. package/test/functional/deprecated/commandsFunctional.js +0 -108
  24. package/test/functional/deprecated/iDataQueueFunctional.js +0 -103
  25. package/test/functional/deprecated/iNetworkFunctional.js +0 -159
  26. package/test/functional/deprecated/iObjFunctional.js +0 -349
  27. package/test/functional/deprecated/iPgmFunctional.js +0 -104
  28. package/test/functional/deprecated/iProdFunctional.js +0 -160
  29. package/test/functional/deprecated/iSqlFunctional.js +0 -453
  30. package/test/functional/deprecated/iUserSpaceFunctional.js +0 -138
  31. package/test/functional/deprecated/iWorkFunctional.js +0 -238
  32. package/test/functional/iDataQueueFunctional.js +0 -83
  33. package/test/functional/iNetworkFunctional.js +0 -131
  34. package/test/functional/iObjFunctional.js +0 -326
  35. package/test/functional/iProdFunctional.js +0 -134
  36. package/test/functional/iSqlFunctional.js +0 -448
  37. package/test/functional/iUserSpaceFunctional.js +0 -134
  38. package/test/functional/iWorkFunctional.js +0 -215
  39. package/test/unit/CommandCallUnit.js +0 -87
  40. package/test/unit/ConnectionUnit.js +0 -188
  41. package/test/unit/ProgamCallUnit.js +0 -281
  42. package/test/unit/deprecated/commandsUnit.js +0 -87
  43. package/test/unit/deprecated/iConnUnit.js +0 -158
  44. package/test/unit/deprecated/iPgmUnit.js +0 -211
  45. package/test/unit/deprecated/iSqlUnit.js +0 -441
  46. package/test/unit/deprecated/xmlToJsonUnit.js +0 -200
@@ -1,211 +0,0 @@
1
- // Copyright (c) International Business Machines Corp. 2019
2
-
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
- // associated documentation files (the "Software"), to deal in the Software without restriction,
5
- // including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
- // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
- // furnished to do so, subject to the following conditions:
8
-
9
- // The above copyright notice and this permission notice shall be included in all copies or
10
- // substantial portions of the Software.
11
-
12
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
- // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- /* eslint-disable new-cap */
19
-
20
- const { expect } = require('chai');
21
- const { iPgm } = require('../../../lib/itoolkit');
22
-
23
- const outBuf = [
24
- [0, '10i0'],
25
- [0, '10i0'],
26
- ['', '36h'],
27
- ['', '10A'],
28
- ['', '1A'],
29
- ['', '1A'],
30
- [0, '10i0'],
31
- [0, '10i0'],
32
- ];
33
- const errno = [
34
- [0, '10i0'],
35
- [0, '10i0', { setlen: 'rec2' }],
36
- ['', '7A'],
37
- ['', '1A'],
38
- ];
39
-
40
- describe('iPgm Class Unit Tests', function () {
41
- describe('constructor', function () {
42
- it('creates and returns an instance of iPgm with lib and function set', function () {
43
- const pgm = new iPgm('QTOCNETSTS');
44
- expect(pgm).to.be.instanceOf(iPgm);
45
- });
46
- });
47
-
48
- describe('toXML', function () {
49
- it('returns pgm XML', function () {
50
- const pgm = new iPgm(
51
- 'QTOCNETSTS',
52
- {
53
- lib: 'QSYS',
54
- func: 'QtoRtvTCPA',
55
- error: 'on',
56
- },
57
- );
58
-
59
- const expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'on\'></pgm>';
60
-
61
- expect(pgm.toXML()).to.be.a('string').and.to.equal(expectedXML);
62
- });
63
- });
64
-
65
- describe('addParam', function () {
66
- it('appends param to pgm xml', function () {
67
- const pgm = new iPgm(
68
- 'QTOCNETSTS',
69
- {
70
- lib: 'QSYS',
71
- func: 'QtoRtvTCPA',
72
- error: 'fast',
73
- },
74
- );
75
-
76
- pgm.addParam(outBuf, { io: 'out' });
77
-
78
- let expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
79
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
80
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
81
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
82
- + '0</data><data type=\'10i0\'>0</data></ds></parm></pgm>';
83
-
84
- expect(pgm.toXML()).to.equal(expectedXML);
85
-
86
- pgm.addParam(66, '10i0');
87
-
88
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
89
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
90
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
91
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
92
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
93
- + '<parm><data type=\'10i0\'>66</data></parm></pgm>';
94
-
95
- expect(pgm.toXML()).to.equal(expectedXML);
96
-
97
- pgm.addParam(1, '10i0');
98
-
99
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
100
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
101
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
102
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
103
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
104
- + '<parm><data type=\'10i0\'>66</data></parm>'
105
- + '<parm><data type=\'10i0\'>1</data></parm></pgm>';
106
-
107
- expect(pgm.toXML()).to.equal(expectedXML);
108
-
109
- pgm.addParam('QCCSID', '10A');
110
-
111
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
112
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
113
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
114
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
115
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
116
- + '<parm><data type=\'10i0\'>66</data></parm>'
117
- + '<parm><data type=\'10i0\'>1</data></parm>'
118
- + '<parm><data type=\'10A\'>QCCSID</data></parm></pgm>';
119
-
120
- expect(pgm.toXML()).to.equal(expectedXML);
121
-
122
- pgm.addParam(errno, { io: 'both', len: 'rec2' });
123
-
124
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
125
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
126
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
127
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
128
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
129
- + '<parm><data type=\'10i0\'>66</data></parm>'
130
- + '<parm><data type=\'10i0\'>1</data></parm>'
131
- + '<parm><data type=\'10A\'>QCCSID</data></parm>'
132
- + '<parm io=\'both\'><ds len=\'rec2\'><data type=\'10i0\'>0</data>'
133
- + '<data type=\'10i0\' setlen=\'rec2\'>0</data><data type=\'7A\'>'
134
- + '</data><data type=\'1A\'></data></ds></parm></pgm>';
135
-
136
- expect(pgm.toXML()).to.equal(expectedXML);
137
- });
138
-
139
- it('regular <parm> contains by=\'val\'', function () {
140
- const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
141
-
142
- pgm.addParam('', '1A', { by: 'val' });
143
- pgm.addReturn('', '2A', { name: 'output' });
144
-
145
- const lookAtXML = pgm.toXML();
146
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
147
- });
148
-
149
- it('data structure <parm> contains by=\'val\'', function () {
150
- const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
151
-
152
- const params = [
153
- [0, '3s0'],
154
- [0, '7s0', { name: 'ds_fld2' }],
155
- ];
156
-
157
- pgm.addParam(params, { name: 'inds', by: 'val' });
158
- pgm.addReturn('', '2A', { name: 'output' });
159
-
160
- const lookAtXML = pgm.toXML();
161
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
162
- });
163
-
164
- it('regular <parm> contains by=\'val\', with io=\'both\'', function () {
165
- const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
166
-
167
- pgm.addParam('', '1A', { by: 'val', io: 'both' });
168
- pgm.addReturn('', '2A', { name: 'output' });
169
-
170
- const lookAtXML = pgm.toXML();
171
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
172
- expect(lookAtXML).to.match(/<parm .*io='both'.*>/);
173
- });
174
-
175
- it('data structure <parm> contains by=\'val\', with io=\'both\'', function () {
176
- const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
177
-
178
- const params = [
179
- [0, '3s0'],
180
- [0, '7s0', { name: 'ds_fld2' }],
181
- ];
182
-
183
- pgm.addParam(params, { name: 'inds', by: 'val', io: 'both' });
184
- pgm.addReturn('', '2A', { name: 'output' });
185
-
186
- const lookAtXML = pgm.toXML();
187
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
188
- expect(lookAtXML).to.match(/<parm .*io='both'.*>/);
189
- });
190
- });
191
-
192
- describe('addReturn', function () {
193
- it('appends return to pgm xml', function () {
194
- const pgm = new iPgm(
195
- 'QTOCNETSTS',
196
- {
197
- lib: 'QSYS',
198
- func: 'QtoRtvTCPA',
199
- error: 'fast',
200
- },
201
- );
202
-
203
- pgm.addReturn('0', '20A');
204
-
205
- const expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' '
206
- + 'error=\'fast\'><return><data type=\'20A\'>0</data></return></pgm>';
207
-
208
- expect(pgm.toXML()).to.equal(expectedXML);
209
- });
210
- });
211
- });
@@ -1,441 +0,0 @@
1
- // Copyright (c) International Business Machines Corp. 2019
2
-
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
- // associated documentation files (the "Software"), to deal in the Software without restriction,
5
- // including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
- // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
- // furnished to do so, subject to the following conditions:
8
-
9
- // The above copyright notice and this permission notice shall be included in all copies or
10
- // substantial portions of the Software.
11
-
12
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
- // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- /* eslint-disable new-cap */
19
-
20
- const { expect } = require('chai');
21
- const { iSql } = require('../../../lib/itoolkit');
22
-
23
- describe('iSql Class Unit Tests', function () {
24
- describe('constructor', function () {
25
- it('creates returns an instance of iSql', function () {
26
- const sql = new iSql();
27
-
28
- expect(sql).to.be.instanceOf(iSql);
29
- });
30
- });
31
- describe('toXML', function () {
32
- it('returns current sql XML', function () {
33
- const sql = new iSql();
34
-
35
- const expectedXML = '<sql></sql>';
36
-
37
- expect(sql.toXML()).to.equal(expectedXML);
38
- });
39
- });
40
- describe('addQuery', function () {
41
- it('appends query with error is on to sql XML', function () {
42
- const sql = new iSql();
43
-
44
- const expectedXML = '<sql><query error=\'on\'>select * from QIWS.QCUSTCDT</query></sql>';
45
-
46
- sql.addQuery('select * from QIWS.QCUSTCDT', { error: 'on' });
47
-
48
- expect(sql.toXML()).to.equal(expectedXML);
49
- });
50
- it('appends query with options object to sql XML', function () {
51
- const sql = new iSql();
52
-
53
- const expectedXML = '<sql><query error=\'fast\'>select * from QIWS.QCUSTCDT</query></sql>';
54
-
55
- sql.addQuery('select * from QIWS.QCUSTCDT');
56
-
57
- expect(sql.toXML()).to.equal(expectedXML);
58
- });
59
- });
60
- describe('fetch', function () {
61
- it('appends fetch without options object to sql XML', function () {
62
- const sql = new iSql();
63
-
64
- const expectedXML = '<sql><fetch block=\'all\' desc=\'on\' error=\'fast\'></fetch></sql>';
65
-
66
- sql.fetch();
67
- expect(sql.toXML()).to.equal(expectedXML);
68
- });
69
- it('appends fetch with block is 10 to sql XML', function () {
70
- const sql = new iSql();
71
-
72
- const expectedXML = '<sql><fetch block=\'10\' desc=\'on\' error=\'fast\'></fetch></sql>';
73
-
74
- sql.fetch({ block: '10' });
75
- expect(sql.toXML()).to.equal(expectedXML);
76
- });
77
- it('appends fetch with desc is off to sql XML', function () {
78
- const sql = new iSql();
79
-
80
- const expectedXML = '<sql><fetch block=\'all\' desc=\'off\' error=\'fast\'></fetch></sql>';
81
-
82
- sql.fetch({ desc: 'off' });
83
- expect(sql.toXML()).to.equal(expectedXML);
84
- });
85
- it('appends fetch with error is on to sql XML', function () {
86
- const sql = new iSql();
87
-
88
- const expectedXML = '<sql><fetch block=\'all\' desc=\'on\' error=\'on\'></fetch></sql>';
89
-
90
- sql.fetch({ error: 'on' });
91
- expect(sql.toXML()).to.equal(expectedXML);
92
- });
93
- });
94
- describe('commit', function () {
95
- it('appends commit with action commit to sql XML', function () {
96
- const sql = new iSql();
97
-
98
- const expectedXML = '<sql><commit action=\'commit\' error=\'fast\'></commit></sql>';
99
-
100
- sql.commit({ action: 'commit' });
101
- expect(sql.toXML()).to.equal(expectedXML);
102
- });
103
- it('appends commit with action rollback to sql XML', function () {
104
- const sql = new iSql();
105
-
106
- const expectedXML = '<sql><commit action=\'rollback\' error=\'fast\'></commit></sql>';
107
-
108
- sql.commit({ action: 'rollback' });
109
- expect(sql.toXML()).to.equal(expectedXML);
110
- });
111
- it('appends commit with default action to sql XML', function () {
112
- const sql = new iSql();
113
-
114
- const expectedXML = '<sql><commit action=\'commit\' error=\'fast\'></commit></sql>';
115
-
116
- sql.commit();
117
- expect(sql.toXML()).to.equal(expectedXML);
118
- });
119
- it('appends commit with error is on to sql XML', function () {
120
- const sql = new iSql();
121
-
122
- const expectedXML = '<sql><commit action=\'commit\' error=\'on\'></commit></sql>';
123
-
124
- sql.commit({ action: 'commit', error: 'on' });
125
- expect(sql.toXML()).to.equal(expectedXML);
126
- });
127
- });
128
- describe('prepare', function () {
129
- it('appends prepare to sql XML', function () {
130
- const sql = new iSql();
131
-
132
- const expectedXML = '<sql><prepare error=\'fast\'>SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?</prepare></sql>';
133
-
134
- sql.prepare('SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?');
135
- expect(sql.toXML()).to.equal(expectedXML);
136
- });
137
- it('appends prepare with error on to sql XML', function () {
138
- const sql = new iSql();
139
-
140
- const expectedXML = '<sql><prepare error=\'on\'>SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?</prepare></sql>';
141
-
142
- sql.prepare('SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?', { error: 'on' });
143
- expect(sql.toXML()).to.equal(expectedXML);
144
- });
145
- });
146
-
147
- describe('execute', function () {
148
- it('appends execute with parameters to sql XML', function () {
149
- const sql = new iSql();
150
-
151
- const expectedXML = '<sql><execute error=\'fast\'><parm io=\'in\'>30</parm></execute></sql>';
152
-
153
- sql.execute([[30, 'in']]);
154
- expect(sql.toXML()).to.equal(expectedXML);
155
- });
156
- it('appends execute with parameters and error on to sql XML', function () {
157
- const sql = new iSql();
158
-
159
- const expectedXML = '<sql><execute error=\'on\'><parm io=\'in\'>30</parm></execute></sql>';
160
-
161
- sql.execute([[30, 'in']], { error: 'on' });
162
- expect(sql.toXML()).to.equal(expectedXML);
163
- });
164
- it('appends execute without parameters to sql XML', function () {
165
- const sql = new iSql();
166
-
167
- const expectedXML = '<sql><execute error=\'fast\'></execute></sql>';
168
-
169
- sql.execute();
170
- expect(sql.toXML()).to.equal(expectedXML);
171
- });
172
- it('appends execute without parameters and error on to sql XML', function () {
173
- const sql = new iSql();
174
-
175
- const expectedXML = '<sql><execute error=\'on\'></execute></sql>';
176
-
177
- sql.execute(null, { error: 'on' });
178
- expect(sql.toXML()).to.equal(expectedXML);
179
- });
180
- });
181
- describe('tables', function () {
182
- it('appends tables to sql XML', function () {
183
- const sql = new iSql();
184
-
185
- const expectedXML = '<sql><tables error=\'fast\'><parm></parm><parm>QIWS</parm><parm></parm><parm></parm></tables></sql>';
186
- // catalog, schema, table, table type
187
- sql.tables(['', 'QIWS', '', '']);
188
- expect(sql.toXML()).to.equal(expectedXML);
189
- });
190
- it('appends tables with error on to sql XML', function () {
191
- const sql = new iSql();
192
-
193
- const expectedXML = '<sql><tables error=\'on\'><parm></parm><parm>QIWS</parm><parm></parm><parm></parm></tables></sql>';
194
- // catalog, schema, table, table type
195
- sql.tables(['', 'QIWS', '', ''], { error: 'on' });
196
- expect(sql.toXML()).to.equal(expectedXML);
197
- });
198
- });
199
- describe('tablePriv', function () {
200
- it('appends tablepriv to sql XML', function () {
201
- const sql = new iSql();
202
-
203
- const expectedXML = '<sql><tablepriv error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm></tablepriv></sql>';
204
- // catalog, schema, table
205
- sql.tablePriv(['', 'QIWS', 'QCUSTCDT']);
206
- expect(sql.toXML()).to.equal(expectedXML);
207
- });
208
- it('appends tablepriv with error on to sql XML', function () {
209
- const sql = new iSql();
210
-
211
- const expectedXML = '<sql><tablepriv error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm></tablepriv></sql>';
212
- // catalog, schema, table
213
- sql.tablePriv(['', 'QIWS', 'QCUSTCDT'], { error: 'on' });
214
- expect(sql.toXML()).to.equal(expectedXML);
215
- });
216
- });
217
- describe('columns', function () {
218
- it('appends columns to sql XML', function () {
219
- const sql = new iSql();
220
-
221
- const expectedXML = '<sql><columns error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columns></sql>';
222
- // catalog, schema, table, column
223
- sql.columns(['', 'QIWS', 'QCUSTCDT', '']);
224
- expect(sql.toXML()).to.equal(expectedXML);
225
- });
226
- it('appends columns with error on to sql XML', function () {
227
- const sql = new iSql();
228
-
229
- const expectedXML = '<sql><columns error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columns></sql>';
230
- // catalog, schema, table, column
231
- sql.columns(['', 'QIWS', 'QCUSTCDT', ''], { error: 'on' });
232
- expect(sql.toXML()).to.equal(expectedXML);
233
- });
234
- });
235
- describe('columnPriv', function () {
236
- it('appends columnpriv to sql XML', function () {
237
- const sql = new iSql();
238
-
239
- const expectedXML = '<sql><columnpriv error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columnpriv></sql>';
240
- // catalog, schema, table, column
241
- sql.columnPriv(['', 'QIWS', 'QCUSTCDT', '']);
242
- expect(sql.toXML()).to.equal(expectedXML);
243
- });
244
- it('appends columnpriv with error on to sql XML', function () {
245
- const sql = new iSql();
246
-
247
- const expectedXML = '<sql><columnpriv error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columnpriv></sql>';
248
- // catalog, schema, table, column
249
- sql.columnPriv(['', 'QIWS', 'QCUSTCDT', ''], { error: 'on' });
250
- expect(sql.toXML()).to.equal(expectedXML);
251
- });
252
- });
253
- describe('procedures', function () {
254
- it('appends procedures to sql XML', function () {
255
- const sql = new iSql();
256
-
257
- const expectedXML = '<sql><procedures error=\'fast\'><parm></parm><parm>QSYS2</parm><parm>TCPIP_INFO</parm></procedures></sql>';
258
- // catalog, schema, procedure
259
- sql.procedures(['', 'QSYS2', 'TCPIP_INFO']);
260
- expect(sql.toXML()).to.equal(expectedXML);
261
- });
262
- it('appends procedures with error on to sql XML', function () {
263
- const sql = new iSql();
264
-
265
- const expectedXML = '<sql><procedures error=\'on\'><parm></parm><parm>QSYS2</parm><parm>TCPIP_INFO</parm></procedures></sql>';
266
- // catalog, schema, procedure
267
- sql.procedures(['', 'QSYS2', 'TCPIP_INFO'], { error: 'on' });
268
- expect(sql.toXML()).to.equal(expectedXML);
269
- });
270
- });
271
- describe('pColumns', function () {
272
- it('appends pColumns to sql XML', function () {
273
- // procedure columns:
274
- const sql = new iSql();
275
-
276
- const expectedXML = '<sql><pcolumns error=\'fast\'><parm></parm><parm>QSYS2</parm><parm>QCMDEXC</parm><parm>COMMAND</parm></pcolumns></sql>';
277
- // catalog, schema, procedure, column
278
- sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']);
279
- expect(sql.toXML()).to.equal(expectedXML);
280
- });
281
- it('appends pColumns with error on to sql XML', function () {
282
- // procedure columns:
283
- const sql = new iSql();
284
-
285
- const expectedXML = '<sql><pcolumns error=\'on\'><parm></parm><parm>QSYS2</parm><parm>QCMDEXC</parm><parm>COMMAND</parm></pcolumns></sql>';
286
- // catalog, schema, procedure, column
287
- sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND'], { error: 'on' });
288
- expect(sql.toXML()).to.equal(expectedXML);
289
- });
290
- });
291
- describe('primaryKeys', function () {
292
- it('appends primarykeys to sql XML', function () {
293
- const sql = new iSql();
294
-
295
- const expectedXML = '<sql><primarykeys error=\'fast\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></primarykeys></sql>';
296
- // catalog, schema, table
297
- sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']);
298
- expect(sql.toXML()).to.equal(expectedXML);
299
- });
300
- it('appends primarykeys with error on to sql XML', function () {
301
- const sql = new iSql();
302
-
303
- const expectedXML = '<sql><primarykeys error=\'on\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></primarykeys></sql>';
304
- // catalog, schema, table
305
- sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX'], { error: 'on' });
306
- expect(sql.toXML()).to.equal(expectedXML);
307
- });
308
- });
309
- describe('foreignKeys', function () {
310
- it('appends foreignkeys to sql XML', function () {
311
- const sql = new iSql();
312
-
313
- const expectedXML = '<sql><foreignkeys error=\'fast\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRC</parm><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></foreignkeys></sql>';
314
-
315
- // pk: catalog, schema, table
316
- // fk: catalog, schema, table
317
- sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']);
318
- expect(sql.toXML()).to.equal(expectedXML);
319
- });
320
- it('appends foreignkeys with error on to sql XML', function () {
321
- const sql = new iSql();
322
-
323
- const expectedXML = '<sql><foreignkeys error=\'on\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRC</parm><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></foreignkeys></sql>';
324
-
325
- // pk: catalog, schema, table
326
- // fk: catalog, schema, table
327
- sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX'], { error: 'on' });
328
- expect(sql.toXML()).to.equal(expectedXML);
329
- });
330
- });
331
- describe('statistics', function () {
332
- it('appends statistics to sql XML', function () {
333
- const sql = new iSql();
334
-
335
- const expectedXML = '<sql><statistics error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>all</parm></statistics></sql>';
336
- // catalog, schema, table, all | unique
337
- sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']);
338
- expect(sql.toXML()).to.equal(expectedXML);
339
- });
340
- it('appends statistics with error on to sql XML', function () {
341
- const sql = new iSql();
342
-
343
- const expectedXML = '<sql><statistics error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>all</parm></statistics></sql>';
344
- // catalog, schema, table, all | unique
345
- sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all'], { error: 'on' });
346
- expect(sql.toXML()).to.equal(expectedXML);
347
- });
348
- });
349
- describe('special', function () {
350
- it('appends special to sql XML', function () {
351
- const sql = new iSql();
352
-
353
- const expectedXML = '<sql><special error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>row</parm><parm>no</parm></special></sql>';
354
- // catalog, schema, table, row | transaction | session, no | unique
355
- sql.special(['', 'QIWS', 'QCUSTCDT', 'row', 'no']);
356
- expect(sql.toXML()).to.equal(expectedXML);
357
- });
358
- it('appends special with error on to sql XML', function () {
359
- const sql = new iSql();
360
-
361
- const expectedXML = '<sql><special error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>row</parm><parm>no</parm></special></sql>';
362
- // catalog, schema, table, row | transaction | session, no | unique
363
- sql.special(['', 'QIWS', 'QCUSTCDT', 'row', 'no'], { error: 'on' });
364
- expect(sql.toXML()).to.equal(expectedXML);
365
- });
366
- });
367
- describe('count', function () {
368
- it('appends count to sql XML', function () {
369
- const sql = new iSql();
370
-
371
- const expectedXML = '<sql><count desc=\'both\' error=\'fast\'></count></sql>';
372
- sql.count({ desc: 'both' });
373
- expect(sql.toXML()).to.equal(expectedXML);
374
- });
375
- it('appends count without options object to sql XML', function () {
376
- const sql = new iSql();
377
-
378
- const expectedXML = '<sql><count desc=\'both\' error=\'fast\'></count></sql>';
379
- sql.count();
380
- expect(sql.toXML()).to.equal(expectedXML);
381
- });
382
- it('appends count with error on to sql XML', function () {
383
- const sql = new iSql();
384
-
385
- const expectedXML = '<sql><count desc=\'both\' error=\'on\'></count></sql>';
386
- sql.count({ error: 'on' });
387
- expect(sql.toXML()).to.equal(expectedXML);
388
- });
389
- });
390
- describe('rowCount', function () {
391
- it('appends rowcount to sql XML', function () {
392
- const sql = new iSql();
393
-
394
- const expectedXML = '<sql><rowcount error=\'fast\'></rowcount></sql>';
395
- sql.rowCount();
396
- expect(sql.toXML()).to.equal(expectedXML);
397
- });
398
- it('appends rowcount with error on to sql XML', function () {
399
- const sql = new iSql();
400
-
401
- const expectedXML = '<sql><rowcount error=\'on\'></rowcount></sql>';
402
- sql.rowCount({ error: 'on' });
403
- expect(sql.toXML()).to.equal(expectedXML);
404
- });
405
- });
406
- describe('free', function () {
407
- it('appends free to sql XML', function () {
408
- const sql = new iSql();
409
-
410
- const expectedXML = '<sql><free></free></sql>';
411
- sql.free();
412
- expect(sql.toXML()).to.equal(expectedXML);
413
- });
414
- });
415
- describe('describe', function () {
416
- it('appends describe to sql XML', function () {
417
- const sql = new iSql();
418
-
419
- const expectedXML = '<sql><describe desc=\'both\' error=\'fast\'></describe></sql>';
420
-
421
- sql.describe({ desc: 'both' });
422
- expect(sql.toXML()).to.equal(expectedXML);
423
- });
424
- it('appends describe without options object to sql XML', function () {
425
- const sql = new iSql();
426
-
427
- const expectedXML = '<sql><describe desc=\'both\' error=\'fast\'></describe></sql>';
428
-
429
- sql.describe();
430
- expect(sql.toXML()).to.equal(expectedXML);
431
- });
432
- it('appends describe with error on to sql XML', function () {
433
- const sql = new iSql();
434
-
435
- const expectedXML = '<sql><describe desc=\'both\' error=\'on\'></describe></sql>';
436
-
437
- sql.describe({ error: 'on' });
438
- expect(sql.toXML()).to.equal(expectedXML);
439
- });
440
- });
441
- });