write basic AppManager tests

pull/5370/head
Omkara 6 years ago
parent cc42642ec6
commit 9c4f9dbca9
  1. 5
      remix-resolve/src/index.ts
  2. 18
      remix-resolve/src/resolve.ts
  3. 51
      remix-resolve/tests/test.ts

@ -1,6 +1 @@
/*
const rr = require('remix-resolve')
const fileContent = rr.resolve('https://github.com/ethereum/greeter.sol')
const input = rr.combineSource({ 'greeter.sol': content })
*/
export * from './resolve'

@ -1,4 +1,22 @@
import axios from 'axios'
import { Api, PluginProfile } from 'remix-plugin'
export interface RemixResolve extends Api {
type: 'remix-resolve'
events: {}
resolve: any
}
export const RemixResolveProfile: PluginProfile<RemixResolve> = {
type: 'remix-resolve',
methods: ['resolve'],
events: [],
notifications: [],
url: ''
}
export interface Imported {
content: string;
cleanURL: string;

@ -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 {
modules: {},
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')
})
})
})

Loading…
Cancel
Save