diff options
author | F. Eugene Aumson <gene@aumson.org> | 2018-09-14 01:56:10 +0800 |
---|---|---|
committer | F. Eugene Aumson <gene@aumson.org> | 2018-09-18 05:49:14 +0800 |
commit | a75981da148c8a300544a559bc01be1770d443cf (patch) | |
tree | 4f6955ae7abf14ad1b6b7d393bf46d4a29e1c4b1 /packages/sol-doc/test/solidity_doc_generator_test.ts | |
parent | d5f964b58e755ccf1e63a61a97da1c161cf22b22 (diff) | |
download | dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.tar dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.tar.gz dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.tar.bz2 dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.tar.lz dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.tar.xz dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.tar.zst dexon-0x-contracts-a75981da148c8a300544a559bc01be1770d443cf.zip |
test w/&w/out devdoc content in contract
Diffstat (limited to 'packages/sol-doc/test/solidity_doc_generator_test.ts')
-rw-r--r-- | packages/sol-doc/test/solidity_doc_generator_test.ts | 132 |
1 files changed, 76 insertions, 56 deletions
diff --git a/packages/sol-doc/test/solidity_doc_generator_test.ts b/packages/sol-doc/test/solidity_doc_generator_test.ts index b71cce6e7..47289c7c6 100644 --- a/packages/sol-doc/test/solidity_doc_generator_test.ts +++ b/packages/sol-doc/test/solidity_doc_generator_test.ts @@ -12,67 +12,26 @@ import { chaiSetup } from './util/chai_setup'; chaiSetup.configure(); const expect = chai.expect; -describe('#SolidityDocGenerator', async () => { +describe('#SolidityDocGenerator', () => { + it('should generate a doc object that matches the devdoc-free fixture', async () => { + const doc = await generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [ + 'TokenTransferProxyNoDevdoc', + ]); + expect(doc).to.not.be.undefined(); + + verifyTokenTransferProxyABIIsDocumented(doc, 'TokenTransferProxyNoDevdoc'); + }); const docPromises: Array<Promise<DocAgnosticFormat>> = [ generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`), generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, []), generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, ['TokenTransferProxy']), ]; docPromises.forEach(docPromise => { - it('should generate a doc object that matches the TokenTransferProxy fixture', async () => { + it('should generate a doc object that matches the fixture', async () => { const doc = await docPromise; expect(doc).to.not.be.undefined(); - expect(doc.TokenTransferProxy).to.not.be.undefined(); - expect(doc.TokenTransferProxy.constructors).to.not.be.undefined(); - const tokenTransferProxyConstructorCount = 0; - const tokenTransferProxyMethodCount = 8; - const tokenTransferProxyEventCount = 3; - expect(doc.TokenTransferProxy.constructors.length).to.equal(tokenTransferProxyConstructorCount); - expect(doc.TokenTransferProxy.methods.length).to.equal(tokenTransferProxyMethodCount); - if (_.isUndefined(doc.TokenTransferProxy.events)) { - throw new Error('events should never be undefined'); - } - expect(doc.TokenTransferProxy.events.length).to.equal(tokenTransferProxyEventCount); - - expect(doc.Ownable).to.not.be.undefined(); - expect(doc.Ownable.constructors).to.not.be.undefined(); - expect(doc.Ownable.methods).to.not.be.undefined(); - const ownableConstructorCount = 1; - const ownableMethodCount = 2; - const ownableEventCount = 1; - expect(doc.Ownable.constructors.length).to.equal(ownableConstructorCount); - expect(doc.Ownable.methods.length).to.equal(ownableMethodCount); - if (_.isUndefined(doc.Ownable.events)) { - throw new Error('events should never be undefined'); - } - expect(doc.Ownable.events.length).to.equal(ownableEventCount); - - expect(doc.ERC20).to.not.be.undefined(); - expect(doc.ERC20.constructors).to.not.be.undefined(); - expect(doc.ERC20.methods).to.not.be.undefined(); - const erc20ConstructorCount = 0; - const erc20MethodCount = 6; - const erc20EventCount = 2; - expect(doc.ERC20.constructors.length).to.equal(erc20ConstructorCount); - expect(doc.ERC20.methods.length).to.equal(erc20MethodCount); - if (_.isUndefined(doc.ERC20.events)) { - throw new Error('events should never be undefined'); - } - expect(doc.ERC20.events.length).to.equal(erc20EventCount); - - expect(doc.ERC20Basic).to.not.be.undefined(); - expect(doc.ERC20Basic.constructors).to.not.be.undefined(); - expect(doc.ERC20Basic.methods).to.not.be.undefined(); - const erc20BasicConstructorCount = 0; - const erc20BasicMethodCount = 3; - const erc20BasicEventCount = 1; - expect(doc.ERC20Basic.constructors.length).to.equal(erc20BasicConstructorCount); - expect(doc.ERC20Basic.methods.length).to.equal(erc20BasicMethodCount); - if (_.isUndefined(doc.ERC20Basic.events)) { - throw new Error('events should never be undefined'); - } - expect(doc.ERC20Basic.events.length).to.equal(erc20BasicEventCount); + verifyTokenTransferProxyABIIsDocumented(doc, 'TokenTransferProxy'); let addAuthorizedAddressMethod: SolidityMethod | undefined; for (const method of doc.TokenTransferProxy.methods) { @@ -80,10 +39,6 @@ describe('#SolidityDocGenerator', async () => { addAuthorizedAddressMethod = method; } } - expect( - addAuthorizedAddressMethod, - `method addAuthorizedAddress not found in ${JSON.stringify(doc.TokenTransferProxy.methods)}`, - ).to.not.be.undefined(); const tokenTransferProxyAddAuthorizedAddressComment = 'Authorizes an address.'; expect((addAuthorizedAddressMethod as SolidityMethod).comment).to.equal( tokenTransferProxyAddAuthorizedAddressComment, @@ -91,3 +46,68 @@ describe('#SolidityDocGenerator', async () => { }); }); }); + +function verifyTokenTransferProxyABIIsDocumented(doc: DocAgnosticFormat, contractName: string): void { + expect(doc[contractName]).to.not.be.undefined(); + expect(doc[contractName].constructors).to.not.be.undefined(); + const tokenTransferProxyConstructorCount = 0; + const tokenTransferProxyMethodCount = 8; + const tokenTransferProxyEventCount = 3; + expect(doc[contractName].constructors.length).to.equal(tokenTransferProxyConstructorCount); + expect(doc[contractName].methods.length).to.equal(tokenTransferProxyMethodCount); + const events = doc[contractName].events; + if (_.isUndefined(events)) { + throw new Error('events should never be undefined'); + } + expect(events.length).to.equal(tokenTransferProxyEventCount); + + expect(doc.Ownable).to.not.be.undefined(); + expect(doc.Ownable.constructors).to.not.be.undefined(); + expect(doc.Ownable.methods).to.not.be.undefined(); + const ownableConstructorCount = 1; + const ownableMethodCount = 2; + const ownableEventCount = 1; + expect(doc.Ownable.constructors.length).to.equal(ownableConstructorCount); + expect(doc.Ownable.methods.length).to.equal(ownableMethodCount); + if (_.isUndefined(doc.Ownable.events)) { + throw new Error('events should never be undefined'); + } + expect(doc.Ownable.events.length).to.equal(ownableEventCount); + + expect(doc.ERC20).to.not.be.undefined(); + expect(doc.ERC20.constructors).to.not.be.undefined(); + expect(doc.ERC20.methods).to.not.be.undefined(); + const erc20ConstructorCount = 0; + const erc20MethodCount = 6; + const erc20EventCount = 2; + expect(doc.ERC20.constructors.length).to.equal(erc20ConstructorCount); + expect(doc.ERC20.methods.length).to.equal(erc20MethodCount); + if (_.isUndefined(doc.ERC20.events)) { + throw new Error('events should never be undefined'); + } + expect(doc.ERC20.events.length).to.equal(erc20EventCount); + + expect(doc.ERC20Basic).to.not.be.undefined(); + expect(doc.ERC20Basic.constructors).to.not.be.undefined(); + expect(doc.ERC20Basic.methods).to.not.be.undefined(); + const erc20BasicConstructorCount = 0; + const erc20BasicMethodCount = 3; + const erc20BasicEventCount = 1; + expect(doc.ERC20Basic.constructors.length).to.equal(erc20BasicConstructorCount); + expect(doc.ERC20Basic.methods.length).to.equal(erc20BasicMethodCount); + if (_.isUndefined(doc.ERC20Basic.events)) { + throw new Error('events should never be undefined'); + } + expect(doc.ERC20Basic.events.length).to.equal(erc20BasicEventCount); + + let addAuthorizedAddressMethod: SolidityMethod | undefined; + for (const method of doc[contractName].methods) { + if (method.name === 'addAuthorizedAddress') { + addAuthorizedAddressMethod = method; + } + } + expect( + addAuthorizedAddressMethod, + `method addAuthorizedAddress not found in ${JSON.stringify(doc[contractName].methods)}`, + ).to.not.be.undefined(); +} |