aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-doc/test
diff options
context:
space:
mode:
authorF. Eugene Aumson <gene@aumson.org>2018-08-29 23:01:04 +0800
committerF. Eugene Aumson <gene@aumson.org>2018-08-31 21:12:27 +0800
commit823b6c4d7df56e6bc517b72878fb1ff5823a5b6f (patch)
treed8a13f5ed7790c482437491071abd62e3c282512 /packages/sol-doc/test
parent8d122006baa7efdf8bd7a7df7b140a66c7d988af (diff)
downloaddexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.tar
dexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.tar.gz
dexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.tar.bz2
dexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.tar.lz
dexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.tar.xz
dexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.tar.zst
dexon-sol-tools-823b6c4d7df56e6bc517b72878fb1ff5823a5b6f.zip
transform solc's ABI output into doc types
Diffstat (limited to 'packages/sol-doc/test')
-rw-r--r--packages/sol-doc/test/solidity_doc_generator_test.ts52
1 files changed, 47 insertions, 5 deletions
diff --git a/packages/sol-doc/test/solidity_doc_generator_test.ts b/packages/sol-doc/test/solidity_doc_generator_test.ts
index 1df3e5b44..df6ad8e54 100644
--- a/packages/sol-doc/test/solidity_doc_generator_test.ts
+++ b/packages/sol-doc/test/solidity_doc_generator_test.ts
@@ -1,7 +1,11 @@
+import * as _ from 'lodash';
+
import * as chai from 'chai';
import 'mocha';
-import { SolidityDocGenerator } from '../src/solidity_doc_generator';
+import { DocSection } from '@0xproject/types';
+
+import { generateSolDocAsync } from '../src/solidity_doc_generator';
import { chaiSetup } from './util/chai_setup';
@@ -9,11 +13,49 @@ chaiSetup.configure();
const expect = chai.expect;
describe('#SolidityDocGenerator', () => {
- it('should generate', async () => {
- const generator = new SolidityDocGenerator(`${__dirname}/../../test/fixtures/contracts`);
-
- const doc = await generator.generateAsync(['TokenTransferProxy']);
+ it('should generate a doc object that matches the TokenTransferProxy fixture', async () => {
+ const doc = await generateSolDocAsync(['TokenTransferProxy'], `${__dirname}/../../test/fixtures/contracts`);
expect(doc).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);
+
+ 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);
+
+ 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);
+
+ 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);
});
});