|
1 | 1 | /*globals describe, it*/ |
2 | 2 | const File = require('../lib/core/file'); |
3 | 3 | const fs = require('fs-extra'); |
| 4 | +const path = require('path'); |
| 5 | +const assert = require('assert'); |
| 6 | +const sinon = require('sinon'); |
4 | 7 |
|
5 | 8 | describe('embark.File', function () { |
6 | 9 | describe('parseFileForImport', () => { |
7 | 10 | it('should find all the imports', function (done) { |
8 | | - const contract = fs.readFileSync('./test/contracts/simple_storage.sol').toString(); |
| 11 | + const contract = fs.readFileSync('./test/contracts/contract_with_import.sol').toString(); |
9 | 12 | const file = new File({filename: '.embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol', |
10 | 13 | path: 'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/simple_storage.sol'}); |
| 14 | + const downloadFileStub = sinon.stub(file, 'downloadFile') |
| 15 | + .callsFake((path, url, cb) => { |
| 16 | + cb(); |
| 17 | + }); |
| 18 | + |
11 | 19 | file.parseFileForImport(contract, () => { |
| 20 | + assert.strictEqual(downloadFileStub.callCount, 1); |
| 21 | + assert.strictEqual(downloadFileStub.firstCall.args[0], |
| 22 | + path.normalize('.embark/contracts/embark-framework/embark/master/test_app/app/contracts/ownable.sol')); |
| 23 | + assert.strictEqual(downloadFileStub.firstCall.args[1], |
| 24 | + 'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/./ownable.sol'); |
12 | 25 | done(); |
13 | 26 | }); |
14 | 27 | }); |
|
0 commit comments