diff --git a/test/functional/deprecated/commandsFunctional.js b/test/functional/deprecated/commandsFunctional.js index 36e8815d..36e3422f 100644 --- a/test/functional/deprecated/commandsFunctional.js +++ b/test/functional/deprecated/commandsFunctional.js @@ -47,6 +47,16 @@ if (config.transport === 'rest') { describe('iSh, iCmd, iQsh, Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', function () { + // capture depreacation warnings but no-op + // test/unit/commandsUnit.js already ensures deprecations are emited + }); + }); + + after(function () { + process.removeAllListeners('deprecation', function () { + // no-op + }); }); describe('iCmd()', function () { diff --git a/test/functional/deprecated/iDataQueueFunctional.js b/test/functional/deprecated/iDataQueueFunctional.js index eb10a070..18774bab 100644 --- a/test/functional/deprecated/iDataQueueFunctional.js +++ b/test/functional/deprecated/iDataQueueFunctional.js @@ -44,21 +44,39 @@ if (config.transport === 'rest') { const lib = 'NODETKTEST'; const dqName = 'TESTQ'; +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + describe('iDataQueue Functional Tests', function () { before('check if data queue exists for tests', function (done) { printConfig(); + process.on('deprecation', deprecationHandler); checkObjectExists(config, dqName, '*DTAQ', (error) => { if (error) { throw error; } done(); }); }); + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); + }); + describe('constructor', function () { it('creates and returns an instance of iDataQueue', function () { const connection = new iConn(database, config.user, password); const dq = new iDataQueue(connection); expect(dq).to.be.instanceOf(iDataQueue); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iDataQueue' is deprecated and will be removed at a later time."); }); }); @@ -70,6 +88,8 @@ describe('iDataQueue Functional Tests', function () { dq.sendToDataQueue(dqName, lib, 'Hello from DQ!', (output) => { expect(output).to.equal(true); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iDataQueue.sendToDataQueue()' is deprecated and will be removed at a later time."); done(); }); }); @@ -83,6 +103,8 @@ describe('iDataQueue Functional Tests', function () { dq.receiveFromDataQueue(dqName, lib, 100, (output) => { expect(output).to.be.a('string').and.to.equal('Hello from DQ!'); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iDataQueue.receiveFromDataQueue()' is deprecated and will be removed at a later time."); done(); }); }); @@ -96,6 +118,8 @@ describe('iDataQueue Functional Tests', function () { dq.clearDataQueue(dqName, lib, (output) => { expect(output).to.equal(true); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iDataQueue.clearDataQueue()' is deprecated and will be removed at a later time."); done(); }); }); diff --git a/test/functional/deprecated/iNetworkFunctional.js b/test/functional/deprecated/iNetworkFunctional.js index 42884b1d..c8519111 100644 --- a/test/functional/deprecated/iNetworkFunctional.js +++ b/test/functional/deprecated/iNetworkFunctional.js @@ -41,9 +41,25 @@ if (config.transport === 'rest') { }; } +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + describe('iNetwork Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); }); describe('constructor', function () { @@ -53,6 +69,8 @@ describe('iNetwork Functional Tests', function () { const net = new iNetwork(connection); expect(net).to.be.instanceOf(iNetwork); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iNetwork' is deprecated and will be removed at a later time."); }); }); @@ -63,6 +81,8 @@ describe('iNetwork Functional Tests', function () { const net = new iNetwork(connection); net.getTCPIPAttr((output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iNetwork.getTCPIPAttr()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('TCP/IPv4_stack_status'); expect(output).to.have.a.property('How_long_active'); @@ -105,6 +125,8 @@ describe('iNetwork Functional Tests', function () { const net = new iNetwork(connection); net.getNetInterfaceData('127.0.0.1', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iNetwork.getNetInterfaceData()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Internet_address'); expect(output).to.have.a.property('Internet_address_binary'); diff --git a/test/functional/deprecated/iObjFunctional.js b/test/functional/deprecated/iObjFunctional.js index b3c538d2..8e68cff3 100644 --- a/test/functional/deprecated/iObjFunctional.js +++ b/test/functional/deprecated/iObjFunctional.js @@ -41,9 +41,25 @@ if (config.transport === 'rest') { }; } +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + describe('iObj Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); }); describe('constructor', function () { @@ -53,6 +69,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); expect(obj).to.be.instanceOf(iObj); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iObj' is deprecated and will be removed at a later time."); }); }); @@ -63,6 +81,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.retrUsrAuth('*PUBLIC', '*PGM', 'XMLCGI', 'QXMLSERV', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.retrUsrAuth()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Object_authority_/_Data_authority'); expect(output).to.have.a.property('Authorization_list_management'); @@ -107,6 +127,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.retrCmdInfo('CRTLIB', '*LIBL', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.retrCmdInfo()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Command_name'); expect(output).to.have.a.property('Command_library_name'); @@ -159,6 +181,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.retrPgmInfo('XMLCGI', 'QXMLSERV', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.retrPgmInfo()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Program_name'); expect(output).to.have.a.property('Program_library_name'); @@ -233,6 +257,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.retrSrvPgmInfo('QZSRVSSL', 'QHTTPSVR', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.retrSrvPgmInfo()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Service_program_name'); expect(output).to.have.a.property('Service_program_name'); @@ -288,6 +314,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.retrUserInfo('QSYS', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.retrUserInfo()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('User_profile_name'); expect(output).to.have.a.property('Previous_sign-on_date_and_time'); @@ -314,6 +342,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.retrUserAuthToObj('/home', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.retrUserAuthToObj()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Profile_name'); expect(output).to.have.a.property('User_or_group_indicator'); @@ -341,6 +371,8 @@ describe('iObj Functional Tests', function () { const obj = new iObj(connection); obj.addToLibraryList('QHTTPSVR', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iObj.addToLibraryList()' is deprecated and will be removed at a later time."); expect(output).to.be.a('boolean').and.to.equal(true); done(); }); diff --git a/test/functional/deprecated/iPgmFunctional.js b/test/functional/deprecated/iPgmFunctional.js index 70ece28b..abb2bce8 100644 --- a/test/functional/deprecated/iPgmFunctional.js +++ b/test/functional/deprecated/iPgmFunctional.js @@ -45,6 +45,16 @@ if (config.transport === 'rest') { describe('iPgm Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', function () { + // capture depreacation warnings but no-op + // test/unit/iPgmUnit.js already ensures deprecations are emited + }); + }); + + after(function () { + process.removeAllListeners('deprecation', function () { + // no-op + }); }); describe('Test iPgm()', function () { diff --git a/test/functional/deprecated/iProdFunctional.js b/test/functional/deprecated/iProdFunctional.js index fce1bfa1..271f8431 100644 --- a/test/functional/deprecated/iProdFunctional.js +++ b/test/functional/deprecated/iProdFunctional.js @@ -41,9 +41,25 @@ if (config.transport === 'rest') { }; } +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + describe('iProd Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); }); describe('constructor', function () { @@ -53,6 +69,8 @@ describe('iProd Functional Tests', function () { const prod = new iProd(connection); expect(prod).to.be.instanceOf(iProd); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iProd' is deprecated and will be removed at a later time."); }); }); @@ -63,6 +81,8 @@ describe('iProd Functional Tests', function () { const prod = new iProd(connection); prod.getPTFInfo('SI67726', (ptf) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iProd.getPTFInfo()' is deprecated and will be removed at a later time"); expect(ptf).to.be.an('Object'); expect(ptf).to.have.a.property('Product_ID'); expect(ptf).to.have.a.property('PTF_ID'); @@ -105,6 +125,8 @@ describe('iProd Functional Tests', function () { const prod = new iProd(connection); prod.getProductInfo('5770DG1', (product) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iProd.getProductInfo()' is deprecated and will be removed at a later time"); expect(product).to.be.an('Object'); expect(product).to.have.a.property('Product_ID'); expect(product).to.have.a.property('Release_level'); @@ -136,6 +158,8 @@ describe('iProd Functional Tests', function () { const prod = new iProd(connection); prod.getInstalledProducts((products) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iProd.getInstalledProducts()' is deprecated and will be removed at a later time"); expect(products).to.be.an('Array'); expect(products.length).to.be.greaterThan(0); diff --git a/test/functional/deprecated/iSqlFunctional.js b/test/functional/deprecated/iSqlFunctional.js index 60d8b5d0..9608c897 100644 --- a/test/functional/deprecated/iSqlFunctional.js +++ b/test/functional/deprecated/iSqlFunctional.js @@ -45,6 +45,16 @@ if (config.transport === 'rest') { describe('iSql Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', function () { + // capture depreacation warnings but no-op + // test/unit/iSqlUnit.js already ensures deprecations are emited + }); + }); + + after(function () { + process.removeAllListeners('deprecation', function () { + // no-op + }); }); describe('prepare & execute', function () { diff --git a/test/functional/deprecated/iUserSpaceFunctional.js b/test/functional/deprecated/iUserSpaceFunctional.js index 2d94c791..3acf8ecb 100644 --- a/test/functional/deprecated/iUserSpaceFunctional.js +++ b/test/functional/deprecated/iUserSpaceFunctional.js @@ -43,9 +43,25 @@ if (config.transport === 'rest') { const lib = 'NODETKTEST'; +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + describe('iUserSpace Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); }); describe('constructor', function () { @@ -55,6 +71,8 @@ describe('iUserSpace Functional Tests', function () { const userSpace = new iUserSpace(connection); expect(userSpace).to.be.instanceOf(iUserSpace); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iUserSpace' is deprecated and will be removed at a later time."); }); }); @@ -70,6 +88,8 @@ describe('iUserSpace Functional Tests', function () { userSpace.createUserSpace(userSpaceName, lib, 'LOG', 50, '*EXCLUDE', description, (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iUserSpace.createUserSpace()' is deprecated and will be removed at a later time."); expect(output).to.be.a('boolean').and.to.equal(true); done(); }); @@ -88,6 +108,8 @@ describe('iUserSpace Functional Tests', function () { userSpace.setUserSpaceData(userSpaceName, lib, msg.length, msg, (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iUserSpace.setUserSpaceData()' is deprecated and will be removed at a later time."); expect(output).to.be.a('boolean').and.to.equal(true); done(); }); @@ -103,6 +125,8 @@ describe('iUserSpace Functional Tests', function () { const userSpaceName = `USP${(config.transport).toUpperCase()}`; userSpace.getUserSpaceData(userSpaceName, lib, 21, (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iUserSpace.getUserSpaceData()' is deprecated ad will be removed at a later time."); expect(output).to.be.a('string').and.to.equal('Hello from userspace!'); done(); }); @@ -118,6 +142,8 @@ describe('iUserSpace Functional Tests', function () { const userSpaceName = `USP${(config.transport).toUpperCase()}`; userSpace.deleteUserSpace(userSpaceName, lib, (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iUserSpace.deleteUserSpace()' is deprecated and will be removed at a later time"); expect(output).to.be.a('boolean').and.to.equal(true); done(); }); diff --git a/test/functional/deprecated/iWorkFunctional.js b/test/functional/deprecated/iWorkFunctional.js index 816f9691..6aa5b5b7 100644 --- a/test/functional/deprecated/iWorkFunctional.js +++ b/test/functional/deprecated/iWorkFunctional.js @@ -42,9 +42,25 @@ if (config.transport === 'rest') { }; } +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + describe('iWork Functional Tests', function () { before(function () { printConfig(); + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); }); describe('constructor', function () { @@ -54,6 +70,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); expect(work).to.be.instanceOf(iWork); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iWork' is deprecated and will be removed at a later time."); }); }); @@ -64,6 +82,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); work.getSysValue('QCENTURY', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iWork.getSysValue()' is deprecated and will be removed at a later time."); expect(output).to.be.a('string').and.to.equal('1'); done(); }); @@ -78,6 +98,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); work.getSysStatus((output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iWork.getSysStatus()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Current_date_and_time'); expect(output).to.have.a.property('System_name'); @@ -108,6 +130,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); work.getSysStatusExt((output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iWork.getSysStatusExt()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Current_date_and_time'); expect(output).to.have.a.property('System_name'); @@ -153,6 +177,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); work.getJobStatus('000000', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iWork.getJobStatus()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Job_status'); expect(output).to.have.a.property('Fully_qualified_job_name'); @@ -168,6 +194,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); work.getJobInfo('SCPF', 'QSYS', '000000', (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iWork.getJobInfo()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Job_name'); expect(output).to.have.a.property('User_name'); @@ -222,6 +250,8 @@ describe('iWork Functional Tests', function () { const work = new iWork(connection); work.getDataArea('NODETKTEST', 'TESTDA', 20, (output) => { + expect(getDeprecation().message).to + .equal("As of v1.0, 'iWork.getDataArea()' is deprecated and will be removed at a later time."); expect(output).to.be.an('Object'); expect(output).to.have.a.property('Type_of_value_returned'); expect(output).to.have.a.property('Library_name'); diff --git a/test/unit/deprecated/commandsUnit.js b/test/unit/deprecated/commandsUnit.js index 1bc7cba1..d6497700 100644 --- a/test/unit/deprecated/commandsUnit.js +++ b/test/unit/deprecated/commandsUnit.js @@ -18,11 +18,36 @@ const { expect } = require('chai'); const { iSh, iQsh, iCmd } = require('../../../lib/itoolkit'); +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + +const iShDepMessage = "As of v1.0, class 'iSh()' is deprecated. Please use 'CommandCall' instead."; +const iCmdDepMessage = "As of v1.0, class 'iCmd()' is deprecated. Please use 'CommandCall' instead."; +const iQshDepMessage = "As of v1.0, class 'iQsh()' is deprecated. Please use 'CommandCall' instead."; + describe('iSh, iCmd, iQsh, Unit Tests', function () { + before(function () { + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeListener('deprecation', deprecationHandler); + }); + describe('iSh function', function () { it('accepts command input and returns XML output', function () { const sh = iSh('ls -lah'); + expect(getDeprecation().message).to.equal(iShDepMessage); + const expectedXML = 'ls -lah'; expect(sh).to.be.a('string').and.to.equal(expectedXML); @@ -34,6 +59,7 @@ describe('iSh, iCmd, iQsh, Unit Tests', function () { }; const sh = iSh('ls -lah', options); + expect(getDeprecation().message).to.equal(iShDepMessage); const expectedXML = 'ls -lah'; @@ -45,6 +71,8 @@ describe('iSh, iCmd, iQsh, Unit Tests', function () { it('accepts command input and returns XML output', function () { const cmd = iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)'); + expect(getDeprecation().message).to.equal(iCmdDepMessage); + const expectedXML = 'RTVJOBA USRLIBL(?) SYSLIBL(?)'; expect(cmd).to.be.a('string').and.to.equal(expectedXML); @@ -56,6 +84,7 @@ describe('iSh, iCmd, iQsh, Unit Tests', function () { }; const cmd = iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)', options); + expect(getDeprecation().message).to.equal(iCmdDepMessage); const expectedXML = 'RTVJOBA USRLIBL(?) SYSLIBL(?)'; @@ -67,6 +96,7 @@ describe('iSh, iCmd, iQsh, Unit Tests', function () { describe('iQsh function', function () { it('accepts command input and returns XML output', function () { const qsh = iQsh('RTVJOBA USRLIBL(?) SYSLIBL(?)'); + expect(getDeprecation().message).to.equal(iQshDepMessage); const expectedXML = 'RTVJOBA USRLIBL(?) SYSLIBL(?)'; @@ -78,6 +108,7 @@ describe('iSh, iCmd, iQsh, Unit Tests', function () { error: 'on', before: '65535', after: '37', rows: 'on', }; const qsh = iQsh('ls -lah', options); + expect(getDeprecation().message).to.equal(iQshDepMessage); const expectedXML = 'ls -lah'; diff --git a/test/unit/deprecated/iConnUnit.js b/test/unit/deprecated/iConnUnit.js index 2160c805..d0289446 100644 --- a/test/unit/deprecated/iConnUnit.js +++ b/test/unit/deprecated/iConnUnit.js @@ -21,7 +21,28 @@ const { expect } = require('chai'); const sinon = require('sinon'); const { iConn, iSh } = require('../../../lib/itoolkit'); +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + +const iConnDepMessage = "As of v1.0, class 'iConn' is deprecated. Please use 'Connection' instead."; + describe('iConn Class Unit Tests', function () { + before(function () { + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); + }); + describe('constructor', function () { it('creates and returns an instance of iConn with idb transport', function () { const database = process.env.TKDB || '*LOCAL'; @@ -29,6 +50,7 @@ describe('iConn Class Unit Tests', function () { const password = process.env.TKPASS || ''; const connection = new iConn(database, username, password); + expect(getDeprecation().message).to.equal(iConnDepMessage); expect(connection).to.be.instanceOf(iConn); expect(connection.connection.transportOptions).to.be.an('Object'); @@ -58,6 +80,8 @@ describe('iConn Class Unit Tests', function () { const connection = new iConn(database, username, password, options); expect(connection).to.be.instanceOf(iConn); + expect(getDeprecation().message).to.equal(iConnDepMessage); + expect(connection.connection.transportOptions).to.be.an('Object'); expect(connection.connection.transportOptions.database).to.equal(database); expect(connection.connection.transportOptions.username).to.equal(username); @@ -80,6 +104,8 @@ describe('iConn Class Unit Tests', function () { const connection = new iConn(database, username, password); connection.add(iSh('ls -lah')); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iConn.add()' is deprecated. Please use 'Connection.add()' instead"); expect(connection.connection.commandList.length).to.equal(1); expect(connection.connection.commandList[0]).to.equal('ls -lah'); }); @@ -94,6 +120,8 @@ describe('iConn Class Unit Tests', function () { const connection = new iConn(database, username, password); connection.debug(true); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iConn.debug()' is deprecated. Please use 'Connection.debug()' instead"); expect(connection.debug()).to.equal(true); connection.debug(false); expect(connection.debug()).to.equal(false); @@ -111,6 +139,8 @@ describe('iConn Class Unit Tests', function () { // iConn.getConnection() calls -> Connection.getTransportOptions() const options = connection.getConnection(); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iConn.getConnection()' is deprecated. Please use 'Connection.getTransportOptions()' instead"); expect(options).to.be.an('Object'); expect(options.database).to.equal(database); @@ -153,6 +183,8 @@ describe('iConn Class Unit Tests', function () { sinon.stub(connection, 'run').yields(xmlOut); + // we dont assert iConn.run deprecation warning is emitted + // because the .run methoh is being mocked here connection.run((result) => { expect(result).to.equal(xmlOut); }); diff --git a/test/unit/deprecated/iPgmUnit.js b/test/unit/deprecated/iPgmUnit.js index 08c240d5..1474e30c 100644 --- a/test/unit/deprecated/iPgmUnit.js +++ b/test/unit/deprecated/iPgmUnit.js @@ -37,10 +37,33 @@ const errno = [ ['', '1A'], ]; +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + +const addParamDepMessage = "As of v1.0, 'iPgm.addParam()' is deprecated. Please use 'ProgramCall.addParam()' instead."; + describe('iPgm Class Unit Tests', function () { + before(function () { + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); + }); + describe('constructor', function () { it('creates and returns an instance of iPgm with lib and function set', function () { const pgm = new iPgm('QTOCNETSTS'); + expect(getDeprecation().message).to + .equal("As of v1.0, class 'iPgm' is deprecated. Please use 'ProgramCall' instead."); expect(pgm).to.be.instanceOf(iPgm); }); }); @@ -57,6 +80,8 @@ describe('iPgm Class Unit Tests', function () { const expectedXML = ''; expect(pgm.toXML()).to.be.a('string').and.to.equal(expectedXML); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iPgm.toXML()' is deprecated. Please use 'ProgramCall.toXML()' instead."); }); }); @@ -70,6 +95,7 @@ describe('iPgm Class Unit Tests', function () { }); pgm.addParam(outBuf, { io: 'out' }); + expect(getDeprecation().message).to.equal(addParamDepMessage); let expectedXML = '' + '0' @@ -136,6 +162,7 @@ describe('iPgm Class Unit Tests', function () { const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' }); pgm.addParam('', '1A', { by: 'val' }); + expect(getDeprecation().message).to.equal(addParamDepMessage); pgm.addReturn('', '2A', { name: 'output' }); const lookAtXML = pgm.toXML(); @@ -151,6 +178,7 @@ describe('iPgm Class Unit Tests', function () { ]; pgm.addParam(params, { name: 'inds', by: 'val' }); + expect(getDeprecation().message).to.equal(addParamDepMessage); pgm.addReturn('', '2A', { name: 'output' }); const lookAtXML = pgm.toXML(); @@ -161,6 +189,7 @@ describe('iPgm Class Unit Tests', function () { const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' }); pgm.addParam('', '1A', { by: 'val', io: 'both' }); + expect(getDeprecation().message).to.equal(addParamDepMessage); pgm.addReturn('', '2A', { name: 'output' }); const lookAtXML = pgm.toXML(); @@ -177,6 +206,7 @@ describe('iPgm Class Unit Tests', function () { ]; pgm.addParam(params, { name: 'inds', by: 'val', io: 'both' }); + expect(getDeprecation().message).to.equal(addParamDepMessage); pgm.addReturn('', '2A', { name: 'output' }); const lookAtXML = pgm.toXML(); @@ -196,6 +226,8 @@ describe('iPgm Class Unit Tests', function () { }); pgm.addReturn('0', '20A'); + expect(getDeprecation().message).to + .equal("As of v1.0, 'iPgm.addReturn()' is deprecated. Please use 'ProgramCall.addReturn()' instead."); const expectedXML = '0'; diff --git a/test/unit/deprecated/iSqlUnit.js b/test/unit/deprecated/iSqlUnit.js index 49bd6661..dbec56c4 100644 --- a/test/unit/deprecated/iSqlUnit.js +++ b/test/unit/deprecated/iSqlUnit.js @@ -20,17 +20,39 @@ const { expect } = require('chai'); const { iSql } = require('../../../lib/itoolkit'); +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + +const iSqlDepMessage = ("As of v1.0, class 'iSql' is deprecated. Use odbc, idb-connector, or idb-pconnector npm package instead."); + describe('iSql Class Unit Tests', function () { + before(function () { + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); + }); + describe('constructor', function () { it('creates returns an instance of iSql', function () { const sql = new iSql(); - + expect(getDeprecation().message).to.equal(iSqlDepMessage); expect(sql).to.be.instanceOf(iSql); }); }); describe('toXML', function () { it('returns current sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -40,6 +62,7 @@ describe('iSql Class Unit Tests', function () { describe('addQuery', function () { it('appends query with error is on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'select * from QIWS.QCUSTCDT'; @@ -49,6 +72,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends query with options object to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'select * from QIWS.QCUSTCDT'; @@ -60,6 +84,7 @@ describe('iSql Class Unit Tests', function () { describe('fetch', function () { it('appends fetch without options object to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -68,6 +93,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends fetch with block is 10 to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -76,6 +102,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends fetch with desc is off to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -84,6 +111,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends fetch with error is on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -94,6 +122,7 @@ describe('iSql Class Unit Tests', function () { describe('commit', function () { it('appends commit with action commit to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -102,6 +131,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends commit with action rollback to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -110,6 +140,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends commit with default action to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -118,6 +149,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends commit with error is on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -128,6 +160,7 @@ describe('iSql Class Unit Tests', function () { describe('prepare', function () { it('appends prepare to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?'; @@ -136,6 +169,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends prepare with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?'; @@ -147,6 +181,7 @@ describe('iSql Class Unit Tests', function () { describe('execute', function () { it('appends execute with parameters to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = '30'; @@ -155,6 +190,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends execute with parameters and error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = '30'; @@ -163,6 +199,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends execute without parameters to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -171,6 +208,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends execute without parameters and error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -181,6 +219,7 @@ describe('iSql Class Unit Tests', function () { describe('tables', function () { it('appends tables to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWS'; // catalog, schema, table, table type @@ -189,6 +228,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends tables with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWS'; // catalog, schema, table, table type @@ -199,6 +239,7 @@ describe('iSql Class Unit Tests', function () { describe('tablePriv', function () { it('appends tablepriv to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDT'; // catalog, schema, table @@ -207,6 +248,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends tablepriv with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDT'; // catalog, schema, table @@ -217,6 +259,7 @@ describe('iSql Class Unit Tests', function () { describe('columns', function () { it('appends columns to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDT'; // catalog, schema, table, column @@ -225,6 +268,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends columns with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDT'; // catalog, schema, table, column @@ -235,6 +279,7 @@ describe('iSql Class Unit Tests', function () { describe('columnPriv', function () { it('appends columnpriv to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDT'; // catalog, schema, table, column @@ -243,6 +288,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends columnpriv with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDT'; // catalog, schema, table, column @@ -253,6 +299,7 @@ describe('iSql Class Unit Tests', function () { describe('procedures', function () { it('appends procedures to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QSYS2TCPIP_INFO'; // catalog, schema, procedure @@ -261,6 +308,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends procedures with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QSYS2TCPIP_INFO'; // catalog, schema, procedure @@ -272,6 +320,7 @@ describe('iSql Class Unit Tests', function () { it('appends pColumns to sql XML', function () { // procedure columns: const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QSYS2QCMDEXCCOMMAND'; // catalog, schema, procedure, column @@ -281,6 +330,7 @@ describe('iSql Class Unit Tests', function () { it('appends pColumns with error on to sql XML', function () { // procedure columns: const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QSYS2QCMDEXCCOMMAND'; // catalog, schema, procedure, column @@ -291,6 +341,7 @@ describe('iSql Class Unit Tests', function () { describe('primaryKeys', function () { it('appends primarykeys to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QUSRSYSQASZRAIRX'; // catalog, schema, table @@ -299,6 +350,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends primarykeys with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QUSRSYSQASZRAIRX'; // catalog, schema, table @@ -309,6 +361,7 @@ describe('iSql Class Unit Tests', function () { describe('foreignKeys', function () { it('appends foreignkeys to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QUSRSYSQASZRAIRCQUSRSYSQASZRAIRX'; @@ -319,6 +372,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends foreignkeys with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QUSRSYSQASZRAIRCQUSRSYSQASZRAIRX'; @@ -331,6 +385,7 @@ describe('iSql Class Unit Tests', function () { describe('statistics', function () { it('appends statistics to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDTall'; // catalog, schema, table, all | unique @@ -339,6 +394,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends statistics with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDTall'; // catalog, schema, table, all | unique @@ -349,6 +405,7 @@ describe('iSql Class Unit Tests', function () { describe('special', function () { it('appends special to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = 'QIWSQCUSTCDTrowno'; // catalog, schema, table, row | transaction | session, no | unique @@ -357,6 +414,8 @@ describe('iSql Class Unit Tests', function () { }); it('appends special with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); + const expectedXML = 'QIWSQCUSTCDTrowno'; // catalog, schema, table, row | transaction | session, no | unique @@ -367,6 +426,7 @@ describe('iSql Class Unit Tests', function () { describe('count', function () { it('appends count to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; sql.count({ desc: 'both' }); @@ -374,6 +434,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends count without options object to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; sql.count(); @@ -381,6 +442,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends count with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; sql.count({ error: 'on' }); @@ -390,6 +452,7 @@ describe('iSql Class Unit Tests', function () { describe('rowCount', function () { it('appends rowcount to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; sql.rowCount(); @@ -397,6 +460,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends rowcount with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; sql.rowCount({ error: 'on' }); @@ -406,6 +470,7 @@ describe('iSql Class Unit Tests', function () { describe('free', function () { it('appends free to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; sql.free(); @@ -415,6 +480,7 @@ describe('iSql Class Unit Tests', function () { describe('describe', function () { it('appends describe to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -423,6 +489,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends describe without options object to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; @@ -431,6 +498,7 @@ describe('iSql Class Unit Tests', function () { }); it('appends describe with error on to sql XML', function () { const sql = new iSql(); + expect(getDeprecation().message).to.equal(iSqlDepMessage); const expectedXML = ''; diff --git a/test/unit/deprecated/xmlToJsonUnit.js b/test/unit/deprecated/xmlToJsonUnit.js index 60d6d728..fcb57549 100644 --- a/test/unit/deprecated/xmlToJsonUnit.js +++ b/test/unit/deprecated/xmlToJsonUnit.js @@ -18,7 +18,29 @@ const { expect } = require('chai'); const { xmlToJson } = require('../../../lib/itoolkit'); +let deprecation = null; +function deprecationHandler(dep) { + deprecation = dep; +} + +function getDeprecation() { + const temp = deprecation; + deprecation = null; + return temp; +} + +const xmlToJsonDepMessage = "As of v1.0, 'xmlToJson' is deprecated. Use xml2js npm package instead."; + + describe('xmlToJson Tests', function () { + before(function () { + process.on('deprecation', deprecationHandler); + }); + + after(function () { + process.removeAllListeners('deprecation', deprecationHandler); + }); + it('converts CL command XML output to js object', function () { const xmlOut = '' + '+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)' @@ -27,6 +49,7 @@ describe('xmlToJson Tests', function () { + ' QSYS2 QHLPSYS QUSRSYS'; const result = xmlToJson(xmlOut); + expect(getDeprecation().message).to.equal(xmlToJsonDepMessage); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0]).to.be.an('object'); @@ -60,6 +83,7 @@ describe('xmlToJson Tests', function () { + ''; const result = xmlToJson(xmlOut); + expect(getDeprecation().message).to.equal(xmlToJsonDepMessage); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0]).to.be.an('object'); @@ -87,6 +111,7 @@ describe('xmlToJson Tests', function () { + ''; const result = xmlToJson(xmlOut); + expect(getDeprecation().message).to.equal(xmlToJsonDepMessage); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0]).to.be.an('object'); @@ -131,6 +156,7 @@ describe('xmlToJson Tests', function () { `; const result = xmlToJson(xmlOut); + expect(getDeprecation().message).to.equal(xmlToJsonDepMessage); expect(result).to.be.an('array'); expect(result.length).to.equal(1); @@ -176,6 +202,7 @@ describe('xmlToJson Tests', function () { `; const result = xmlToJson(xmlOut); + expect(getDeprecation().message).to.equal(xmlToJsonDepMessage); expect(result).to.be.an('array'); expect(result.length).to.equal(1);