@ -1,9 +1,20 @@
import { expect } from 'chai'
import { ImportResolver , Imported } from '../src'
import { RemixResolve , ImportResolver } from '../src'
import * as fs from 'fs'
import * as path from 'path'
import * as assert from 'assert'
import { AppManager } from 'remix-plugin'
import { Plugin , AppManager , PluginProfile } from 'remix-plugin'
const RemixResolveProfile : PluginProfile < RemixResolve > = {
type : 'remix-resolve' ,
methods : [ 'resolve' ] ,
url : ''
}
interface IAppManager {
module s : { } ,
plugins : {
'remix-resolve' : RemixResolve
}
}
describe ( 'testRunner' , ( ) = > {
describe ( '#resolve' , ( ) = > {
@ -57,31 +68,21 @@ describe('testRunner', () => {
} )
// test IPFShandle
describe ( 'test getting IPFS files' , ( ) = > {
const fileName = 'ipfs://QmeKtwMBqz5Ac7oL8SyTD96mccEzw9X9d39jLb2kgnBYbn'
let results :Imported
before ( async function ( ) {
try {
const resolver : ImportResolver = new ImportResolver ( )
var sources : Imported = await resolver . resolve ( fileName )
results = sources
return
} catch ( e ) {
throw e
}
} )
// AppManager tests
describe ( 'test with AppManager' , ( ) = > {
let app : AppManager < IAppManager >
let api : Plugin < RemixResolve >
it ( 'should have 3 items' , ( ) = > {
assert . equal ( Object . keys ( results ) . length , 3 )
before ( ( ) = > {
api = new Plugin ( RemixResolveProfile )
app = new AppManager ( {
plugins : [ { json : RemixResolveProfile , api } ]
} )
app . activate ( api . type )
} )
it ( 'should returns contract content of given local path' , ( ) = > {
const expt = {
content : 'pragma solidity ^0.5.0;\nimport "./mortal.sol";\n\ncontract Greeter is Mortal {\n /* Define variable greeting of the type string */\n string greeting;\n\n /* This runs when the contract is executed */\n constructor(string memory _greeting) public {\n greeting = _greeting;\n }\n\n /* Main function */\n function greet() public view returns (string memory) {\n return greeting;\n }\n}\n' ,
cleanURL : 'ipfs://QmeKtwMBqz5Ac7oL8SyTD96mccEzw9X9d39jLb2kgnBYbn' ,
type : 'ipfs'
}
assert . deepEqual ( results , expt )
it ( 'Plugin should be added to app' , ( ) = > {
assert . equal ( typeof ( app . calls [ api . type ] . resolve ) , 'function' )
} )
} )
} )