diff options
author | Hsuan Lee <hsuan@cobinhood.com> | 2019-01-19 18:42:04 +0800 |
---|---|---|
committer | Hsuan Lee <hsuan@cobinhood.com> | 2019-01-19 18:42:04 +0800 |
commit | 7ae38906926dc09bc10670c361af0d2bf0050426 (patch) | |
tree | 5fb10ae366b987db09e4ddb4bc3ba0f75404ad08 /packages/abi-gen/test | |
parent | b5fd3c72a08aaa6957917d74c333387a16edf66b (diff) | |
download | dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.gz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.bz2 dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.lz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.xz dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.zst dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.zip |
Update dependency packages
Diffstat (limited to 'packages/abi-gen/test')
-rw-r--r-- | packages/abi-gen/test/utils_test.ts | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/packages/abi-gen/test/utils_test.ts b/packages/abi-gen/test/utils_test.ts deleted file mode 100644 index 820c0c675..000000000 --- a/packages/abi-gen/test/utils_test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import * as chai from 'chai'; -import * as dirtyChai from 'dirty-chai'; -import * as fs from 'fs'; -import 'mocha'; -import * as tmp from 'tmp'; - -import { utils } from '../src/utils'; - -tmp.setGracefulCleanup(); // remove tmp files even if there are failures - -chai.use(dirtyChai); - -const expect = chai.expect; - -describe('makeOutputFileName()', () => { - it('should handle Metacoin usage', () => { - expect(utils.makeOutputFileName('Metacoin')).to.equal('metacoin'); - }); - it('should handle special zrx_token case', () => { - expect(utils.makeOutputFileName('ZRXToken')).to.equal('zrx_token'); - }); - it('should handle special erc_token case', () => { - expect(utils.makeOutputFileName('ERC20Token')).to.equal('erc20_token'); - }); -}); - -describe('writeOutputFile()', () => { - let tempFilePath: string; - before(() => { - tempFilePath = tmp.fileSync( - { discardDescriptor: true }, // close file (so we can update it) - ).name; - }); - it('should write content to output file', () => { - const content = 'hello world'; - - utils.writeOutputFile(tempFilePath, content); - - expect(fs.readFileSync(tempFilePath).toString()).to.equal(content); - }); -}); - -describe('isOutputFileUpToDate()', () => { - it('should throw ENOENT when there is no abi file', () => { - expect(utils.isOutputFileUpToDate.bind('nonexistant1', 'nonexistant2')).to.throw('ENOENT'); - }); - - describe('when the abi input file exists', () => { - let abiFile: string; - before(() => { - abiFile = tmp.fileSync( - { discardDescriptor: true }, // close file (set timestamp) - ).name; - }); - - describe('without an existing output file', () => { - it('should return false', () => { - expect(utils.isOutputFileUpToDate(abiFile, 'nonexistant_file')).to.be.false(); - }); - }); - - describe('with an existing output file', () => { - let outputFile: string; - before(() => { - outputFile = tmp.fileSync( - { discardDescriptor: true }, // close file (set timestamp) - ).name; - const abiFileModTimeMs = fs.statSync(abiFile).mtimeMs; - const outfileModTimeMs = abiFileModTimeMs + 1; - fs.utimesSync(outputFile, outfileModTimeMs, outfileModTimeMs); - }); - - it('should return true when output file is newer than abi file', async () => { - expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.true(); - }); - - it('should return false when output file exists but is older than abi file', () => { - const outFileModTimeMs = fs.statSync(outputFile).mtimeMs; - const abiFileModTimeMs = outFileModTimeMs + 1; - fs.utimesSync(abiFile, abiFileModTimeMs, abiFileModTimeMs); - - expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.false(); - }); - }); - }); -}); |