Commit ce54f4b2 authored by Omkara's avatar Omkara

write basic AppManager tests

parent 6f3f12eb
/*
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' export * from './resolve'
import axios from 'axios' 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 { export interface Imported {
content: string; content: string;
cleanURL: string; cleanURL: string;
......
import { expect } from 'chai' import { RemixResolve, ImportResolver } from '../src'
import { ImportResolver, Imported } from '../src'
import * as fs from 'fs' import * as fs from 'fs'
import * as path from 'path' import * as path from 'path'
import * as assert from 'assert' 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('testRunner', () => {
describe('#resolve', () => { describe('#resolve', () => {
...@@ -57,31 +68,21 @@ describe('testRunner', () => { ...@@ -57,31 +68,21 @@ describe('testRunner', () => {
}) })
// test IPFShandle // test IPFShandle
describe('test getting IPFS files', () => {
const fileName = 'ipfs://QmeKtwMBqz5Ac7oL8SyTD96mccEzw9X9d39jLb2kgnBYbn'
let results:Imported
before(async function() { // AppManager tests
try { describe('test with AppManager', () => {
const resolver: ImportResolver = new ImportResolver() let app: AppManager<IAppManager>
var sources: Imported = await resolver.resolve(fileName) let api: Plugin<RemixResolve>
results = sources
return
} catch (e) {
throw e
}
})
it('should have 3 items', () => { before(() => {
assert.equal(Object.keys(results).length, 3) api = new Plugin(RemixResolveProfile)
app = new AppManager({
plugins: [{ json: RemixResolveProfile, api }]
})
app.activate(api.type)
}) })
it('should returns contract content of given local path', () => { it('Plugin should be added to app', () => {
const expt = { assert.equal(typeof(app.calls[api.type].resolve), 'function')
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)
}) })
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment